myTextBox method
Widget
myTextBox(
- TextEditingController controller,
- String label,
- TextInputType keyboardType,
- void onRefresh(),
- BuildContext context,
Implementation
Widget myTextBox(TextEditingController controller, String label, TextInputType keyboardType, void Function() onRefresh, BuildContext context) {
return TextField(
controller: controller,
keyboardType: keyboardType,
textInputAction: TextInputAction.done,
textCapitalization: TextCapitalization.sentences,
autofocus: false,
enabled: true,
readOnly: false,
obscureText: false,
obscuringCharacter: "*",
keyboardAppearance: Brightness.light,
cursorWidth: 3,
cursorHeight: 22,
cursorColor: Colors.red,
cursorRadius: Radius.circular(5),
cursorErrorColor: Colors.black,
textAlign: TextAlign.start,
textAlignVertical: TextAlignVertical.center,
textDirection: TextDirection.ltr,
decoration: InputDecoration(
labelText: label,
labelStyle: TextStyle(color: Colors.blue),
helperText: label,
helperStyle: TextStyle(color: Colors.green),
hintText: label,
hintStyle: TextStyle(color: Colors.white),
errorText: null,
errorStyle: TextStyle(color: Colors.red),
prefixText: label,
prefixStyle: TextStyle(color: Colors.amber),
border: OutlineInputBorder(),
enabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.green, width: 2)),
focusedBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.blue, width: 2)),
errorBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.red, width: 2)),
focusedErrorBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.orange, width: 2)),
disabledBorder: OutlineInputBorder(borderSide: BorderSide(color: Colors.grey, width: 2)),
filled: true,
fillColor: Colors.grey[200],
alignLabelWithHint: true,
contentPadding: EdgeInsets.symmetric(vertical: 12, horizontal: 16),
),
onChanged: (v) {
controller.text=v;
onRefresh();
},
onEditingComplete: () {},
onSubmitted: (v) {
controller.text=v;
onRefresh();
FocusScope.of(context).unfocus();
},
onTap: () {},
);
}