2020-05-06 17:40:36 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
|
|
|
class BaseTextFormField extends StatelessWidget {
|
2020-06-20 07:10:00 +00:00
|
|
|
BaseTextFormField(
|
|
|
|
{this.controller,
|
|
|
|
this.keyboardType = TextInputType.text,
|
|
|
|
this.textInputAction = TextInputAction.done,
|
|
|
|
this.textAlign = TextAlign.start,
|
|
|
|
this.autovalidate = false,
|
|
|
|
this.hintText = '',
|
|
|
|
this.maxLines = 1,
|
|
|
|
this.inputFormatters,
|
|
|
|
this.textColor,
|
|
|
|
this.hintColor,
|
|
|
|
this.borderColor,
|
|
|
|
this.prefix,
|
2020-07-29 16:55:42 +00:00
|
|
|
this.prefixIcon,
|
2020-06-20 07:10:00 +00:00
|
|
|
this.suffix,
|
|
|
|
this.suffixIcon,
|
|
|
|
this.enabled = true,
|
2020-10-09 18:34:21 +00:00
|
|
|
this.readOnly = false,
|
|
|
|
this.enableInteractiveSelection = true,
|
2020-06-20 07:10:00 +00:00
|
|
|
this.validator,
|
2020-07-29 16:55:42 +00:00
|
|
|
this.textStyle,
|
2020-08-25 18:12:14 +00:00
|
|
|
this.placeholderTextStyle,
|
2020-09-29 17:56:11 +00:00
|
|
|
this.maxLength,
|
2020-10-09 18:34:21 +00:00
|
|
|
this.focusNode,
|
|
|
|
this.initialValue});
|
2020-05-06 17:40:36 +00:00
|
|
|
|
|
|
|
final TextEditingController controller;
|
|
|
|
final TextInputType keyboardType;
|
|
|
|
final TextInputAction textInputAction;
|
|
|
|
final TextAlign textAlign;
|
|
|
|
final bool autovalidate;
|
|
|
|
final String hintText;
|
|
|
|
final int maxLines;
|
|
|
|
final List<TextInputFormatter> inputFormatters;
|
|
|
|
final Color textColor;
|
|
|
|
final Color hintColor;
|
|
|
|
final Color borderColor;
|
2020-05-12 17:46:42 +00:00
|
|
|
final Widget prefix;
|
2020-07-29 16:55:42 +00:00
|
|
|
final Widget prefixIcon;
|
2020-05-12 17:46:42 +00:00
|
|
|
final Widget suffix;
|
2020-05-20 17:28:01 +00:00
|
|
|
final Widget suffixIcon;
|
2020-05-12 17:46:42 +00:00
|
|
|
final bool enabled;
|
2020-05-06 17:40:36 +00:00
|
|
|
final FormFieldValidator<String> validator;
|
2020-06-20 07:10:00 +00:00
|
|
|
final TextStyle placeholderTextStyle;
|
2020-07-29 16:55:42 +00:00
|
|
|
final TextStyle textStyle;
|
2020-08-25 18:12:14 +00:00
|
|
|
final int maxLength;
|
2020-09-29 17:56:11 +00:00
|
|
|
final FocusNode focusNode;
|
2020-10-09 18:34:21 +00:00
|
|
|
final bool readOnly;
|
|
|
|
final bool enableInteractiveSelection;
|
|
|
|
String initialValue;
|
2020-05-06 17:40:36 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return TextFormField(
|
2020-10-09 18:34:21 +00:00
|
|
|
enableInteractiveSelection: enableInteractiveSelection,
|
|
|
|
readOnly: readOnly,
|
|
|
|
initialValue: initialValue,
|
2020-09-29 17:56:11 +00:00
|
|
|
focusNode: focusNode,
|
2020-05-06 17:40:36 +00:00
|
|
|
controller: controller,
|
|
|
|
keyboardType: keyboardType,
|
|
|
|
textInputAction: textInputAction,
|
|
|
|
textAlign: textAlign,
|
|
|
|
autovalidate: autovalidate,
|
|
|
|
maxLines: maxLines,
|
|
|
|
inputFormatters: inputFormatters,
|
2020-05-12 17:46:42 +00:00
|
|
|
enabled: enabled,
|
2020-08-25 18:12:14 +00:00
|
|
|
maxLength: maxLength,
|
2020-10-09 18:34:21 +00:00
|
|
|
style: textStyle ??
|
|
|
|
TextStyle(
|
|
|
|
fontSize: 16.0,
|
|
|
|
color:
|
|
|
|
textColor ?? Theme.of(context).primaryTextTheme.title.color),
|
2020-05-06 17:40:36 +00:00
|
|
|
decoration: InputDecoration(
|
2020-06-20 07:10:00 +00:00
|
|
|
prefix: prefix,
|
2020-07-29 16:55:42 +00:00
|
|
|
prefixIcon: prefixIcon,
|
2020-06-20 07:10:00 +00:00
|
|
|
suffix: suffix,
|
|
|
|
suffixIcon: suffixIcon,
|
|
|
|
hintStyle: placeholderTextStyle ??
|
|
|
|
TextStyle(
|
2020-08-19 17:57:06 +00:00
|
|
|
color: hintColor ?? Theme.of(context).hintColor,
|
2020-06-20 07:10:00 +00:00
|
|
|
fontSize: 16),
|
|
|
|
hintText: hintText,
|
|
|
|
focusedBorder: UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
2020-10-09 18:34:21 +00:00
|
|
|
color: borderColor ??
|
|
|
|
Theme.of(context).primaryTextTheme.title.backgroundColor,
|
2020-06-20 07:10:00 +00:00
|
|
|
width: 1.0)),
|
2020-07-31 15:29:21 +00:00
|
|
|
disabledBorder: UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
2020-10-09 18:34:21 +00:00
|
|
|
color: borderColor ??
|
|
|
|
Theme.of(context).primaryTextTheme.title.backgroundColor,
|
2020-07-31 15:29:21 +00:00
|
|
|
width: 1.0)),
|
2020-06-20 07:10:00 +00:00
|
|
|
enabledBorder: UnderlineInputBorder(
|
|
|
|
borderSide: BorderSide(
|
2020-10-09 18:34:21 +00:00
|
|
|
color: borderColor ??
|
|
|
|
Theme.of(context).primaryTextTheme.title.backgroundColor,
|
2020-06-20 07:10:00 +00:00
|
|
|
width: 1.0))),
|
2020-05-06 17:40:36 +00:00
|
|
|
validator: validator,
|
|
|
|
);
|
|
|
|
}
|
2020-06-20 07:10:00 +00:00
|
|
|
}
|