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