cake_wallet/lib/src/widgets/base_text_form_field.dart

83 lines
2.5 KiB
Dart
Raw Normal View History

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,
this.prefixIcon,
2020-06-20 07:10:00 +00:00
this.suffix,
this.suffixIcon,
this.enabled = true,
this.validator,
this.textStyle,
2020-06-20 07:10:00 +00:00
this.placeholderTextStyle});
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;
final Widget prefix;
final Widget prefixIcon;
final Widget suffix;
final Widget suffixIcon;
final bool enabled;
final FormFieldValidator<String> validator;
2020-06-20 07:10:00 +00:00
final TextStyle placeholderTextStyle;
final TextStyle textStyle;
@override
Widget build(BuildContext context) {
return TextFormField(
controller: controller,
keyboardType: keyboardType,
textInputAction: textInputAction,
textAlign: textAlign,
autovalidate: autovalidate,
maxLines: maxLines,
inputFormatters: inputFormatters,
enabled: enabled,
style: textStyle ?? TextStyle(
2020-06-20 07:10:00 +00:00
fontSize: 16.0,
color: textColor ?? Theme.of(context).primaryTextTheme.title.color),
decoration: InputDecoration(
2020-06-20 07:10:00 +00:00
prefix: prefix,
prefixIcon: prefixIcon,
2020-06-20 07:10:00 +00:00
suffix: suffix,
suffixIcon: suffixIcon,
hintStyle: placeholderTextStyle ??
TextStyle(
color: hintColor ??
Theme.of(context).primaryTextTheme.caption.color,
fontSize: 16),
hintText: hintText,
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: borderColor ?? Theme.of(context).dividerColor,
width: 1.0)),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: borderColor ?? Theme.of(context).dividerColor,
width: 1.0))),
validator: validator,
);
}
2020-06-20 07:10:00 +00:00
}