You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.2 KiB
82 lines
2.2 KiB
import 'package:flutter/material.dart';
|
|
|
|
class MyTextField extends StatelessWidget {
|
|
final TextEditingController controller;
|
|
final String hintText;
|
|
final bool obscureText;
|
|
final TextInputType keyboardType;
|
|
final Widget? suffixIcon;
|
|
final VoidCallback? onTap;
|
|
final Widget? prefixIcon;
|
|
final String? Function(String?)? validator;
|
|
final FocusNode? focusNode;
|
|
final String? errorMsg;
|
|
final String? Function(String?)? onChanged;
|
|
|
|
const MyTextField({
|
|
super.key,
|
|
required this.controller,
|
|
required this.hintText,
|
|
required this.obscureText,
|
|
required this.keyboardType,
|
|
this.suffixIcon,
|
|
this.onTap,
|
|
this.prefixIcon,
|
|
this.validator,
|
|
this.focusNode,
|
|
this.errorMsg,
|
|
this.onChanged
|
|
});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return TextFormField(
|
|
validator: validator,
|
|
controller: controller,
|
|
obscureText: obscureText,
|
|
keyboardType: keyboardType,
|
|
focusNode: focusNode,
|
|
onTap: onTap,
|
|
textInputAction: TextInputAction.next,
|
|
onChanged: onChanged,
|
|
maxLines: 1,
|
|
decoration: InputDecoration(
|
|
|
|
suffixIcon: suffixIcon,
|
|
prefixIcon: prefixIcon,
|
|
contentPadding: EdgeInsets.symmetric(vertical: 15.0, horizontal: 16.0),
|
|
enabledBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(10),
|
|
borderSide: BorderSide(
|
|
color: Colors.grey.withOpacity(0.3),
|
|
width: 1.0
|
|
),
|
|
),
|
|
focusedBorder: OutlineInputBorder(
|
|
borderRadius: BorderRadius.circular(15),
|
|
borderSide: BorderSide(color: Colors.black26),
|
|
),
|
|
fillColor: Colors.white,
|
|
filled: true,
|
|
hintText: hintText,
|
|
alignLabelWithHint: true,
|
|
hintStyle: TextStyle(
|
|
color: Color(0xff6E6E6E),
|
|
fontSize: 16
|
|
|
|
),
|
|
errorText: errorMsg,
|
|
errorStyle: TextStyle(
|
|
fontSize: 12,
|
|
color: Colors.red,
|
|
fontWeight: FontWeight.w500
|
|
),
|
|
errorBorder: OutlineInputBorder(
|
|
borderSide: BorderSide(color: Colors.red),
|
|
borderRadius: BorderRadius.circular(10)
|
|
)
|
|
),
|
|
);
|
|
}
|
|
|
|
} |