229 lines
5.9 KiB
Dart
229 lines
5.9 KiB
Dart
|
// ignore_for_file: must_be_immutable
|
||
|
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter_form_builder/flutter_form_builder.dart';
|
||
|
import 'package:IQ/app/global/static_informs.dart';
|
||
|
import 'package:IQ/app/global/text_widget.dart';
|
||
|
|
||
|
class BuildTextField extends StatelessWidget {
|
||
|
BuildTextField({
|
||
|
Key? key,
|
||
|
required this.name,
|
||
|
this.controller,
|
||
|
this.enabled,
|
||
|
this.expands,
|
||
|
this.initialValue,
|
||
|
this.keyboardType,
|
||
|
this.maxLines,
|
||
|
this.minLines,
|
||
|
this.maxLength,
|
||
|
this.obscureText,
|
||
|
this.onChanged,
|
||
|
this.onEditingComplete,
|
||
|
this.onTap,
|
||
|
this.readOnly,
|
||
|
this.textAlign,
|
||
|
this.textDirection,
|
||
|
this.validator,
|
||
|
this.labelText,
|
||
|
this.border,
|
||
|
this.contentPadding,
|
||
|
this.errorMaxLines,
|
||
|
this.errorText,
|
||
|
this.fillColor,
|
||
|
this.filled,
|
||
|
this.focusColor,
|
||
|
this.hintMaxLines,
|
||
|
this.hintText,
|
||
|
this.hintTextDirection,
|
||
|
this.icon,
|
||
|
this.iconColor,
|
||
|
this.isDense,
|
||
|
this.label,
|
||
|
this.prefix,
|
||
|
this.prefixIcon,
|
||
|
this.prefixIconColor,
|
||
|
this.prefixText,
|
||
|
this.suffix,
|
||
|
this.suffixIcon,
|
||
|
this.suffixIconColor,
|
||
|
this.suffixText,
|
||
|
this.alignLabelWithHint,
|
||
|
this.margin,
|
||
|
this.signup,
|
||
|
this.autoFocus,
|
||
|
this.counter,
|
||
|
this.showCursor,
|
||
|
this.width,
|
||
|
this.height,
|
||
|
this.focusNode,
|
||
|
this.inputColor,
|
||
|
}) : super(key: key);
|
||
|
|
||
|
final String? name;
|
||
|
final TextEditingController? controller;
|
||
|
final bool? enabled;
|
||
|
final bool? expands;
|
||
|
final String? initialValue;
|
||
|
final TextInputType? keyboardType;
|
||
|
final int? maxLines;
|
||
|
final int? minLines;
|
||
|
final int? maxLength;
|
||
|
final bool? obscureText;
|
||
|
final void Function(String?)? onChanged;
|
||
|
final void Function()? onEditingComplete;
|
||
|
final void Function()? onTap;
|
||
|
final bool? readOnly;
|
||
|
final TextAlign? textAlign;
|
||
|
final TextDirection? textDirection;
|
||
|
final String? Function(String?)? validator;
|
||
|
final String? labelText;
|
||
|
InputBorder? border;
|
||
|
final EdgeInsetsGeometry? contentPadding;
|
||
|
final int? errorMaxLines;
|
||
|
final String? errorText;
|
||
|
final Color? fillColor;
|
||
|
final bool? filled;
|
||
|
final Color? focusColor;
|
||
|
final int? hintMaxLines;
|
||
|
final String? hintText;
|
||
|
final TextDirection? hintTextDirection;
|
||
|
final Widget? icon;
|
||
|
final Color? iconColor;
|
||
|
final bool? isDense;
|
||
|
final bool? autoFocus;
|
||
|
final bool? showCursor;
|
||
|
final Widget? label;
|
||
|
final Widget? prefix;
|
||
|
final Widget? prefixIcon;
|
||
|
final Color? prefixIconColor;
|
||
|
final String? prefixText;
|
||
|
final Widget? suffix;
|
||
|
final Widget? suffixIcon;
|
||
|
final Color? suffixIconColor;
|
||
|
final String? suffixText;
|
||
|
final bool? alignLabelWithHint;
|
||
|
final EdgeInsetsGeometry? margin;
|
||
|
final Widget? counter;
|
||
|
bool? signup = true;
|
||
|
final double? width;
|
||
|
final double? height;
|
||
|
final FocusNode? focusNode;
|
||
|
final Color? inputColor;
|
||
|
signupBorder() {
|
||
|
if (signup == true) {
|
||
|
border = OutlineInputBorder(
|
||
|
borderRadius: const BorderRadius.all(
|
||
|
Radius.circular(10),
|
||
|
),
|
||
|
borderSide: BorderSide(
|
||
|
color: borderColor,
|
||
|
width: 2,
|
||
|
),
|
||
|
);
|
||
|
return border;
|
||
|
} else {
|
||
|
border = const UnderlineInputBorder(
|
||
|
borderSide: BorderSide(color: Colors.white),
|
||
|
);
|
||
|
return border;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
signupBorder();
|
||
|
return Container(
|
||
|
margin: margin,
|
||
|
// width: width,
|
||
|
// height: height,
|
||
|
child: FormBuilderTextField(
|
||
|
name: name!,
|
||
|
focusNode: focusNode,
|
||
|
autofocus: autoFocus ?? false,
|
||
|
controller: controller,
|
||
|
enabled: enabled ?? true,
|
||
|
expands: expands ?? false,
|
||
|
initialValue: initialValue,
|
||
|
keyboardType: keyboardType,
|
||
|
maxLines: maxLines ?? 1,
|
||
|
minLines: minLines,
|
||
|
maxLength: maxLength,
|
||
|
obscureText: obscureText ?? false,
|
||
|
onChanged: onChanged,
|
||
|
onEditingComplete: onEditingComplete,
|
||
|
onTap: onTap,
|
||
|
readOnly: readOnly ?? false,
|
||
|
textAlign: textAlign ?? TextAlign.start,
|
||
|
textDirection: textDirection ?? TextDirection.ltr,
|
||
|
validator: validator,
|
||
|
autovalidateMode: AutovalidateMode.onUserInteraction,
|
||
|
showCursor: showCursor,
|
||
|
decoration: InputDecoration(
|
||
|
///
|
||
|
label: label,
|
||
|
icon: icon,
|
||
|
prefix: prefix,
|
||
|
suffix: suffix,
|
||
|
labelText: labelText,
|
||
|
errorText: errorText,
|
||
|
hintText: hintText,
|
||
|
prefixText: prefixText,
|
||
|
suffixText: suffixText,
|
||
|
prefixIcon: prefixIcon,
|
||
|
suffixIcon: suffixIcon,
|
||
|
|
||
|
///
|
||
|
border: border,
|
||
|
disabledBorder: border,
|
||
|
enabledBorder: border,
|
||
|
errorBorder: border,
|
||
|
focusedBorder: border,
|
||
|
focusedErrorBorder: border,
|
||
|
|
||
|
///
|
||
|
contentPadding: contentPadding,
|
||
|
errorMaxLines: errorMaxLines,
|
||
|
hintMaxLines: hintMaxLines,
|
||
|
hintTextDirection: hintTextDirection,
|
||
|
alignLabelWithHint: alignLabelWithHint,
|
||
|
counter: counter,
|
||
|
|
||
|
///
|
||
|
filled: filled,
|
||
|
isDense: isDense,
|
||
|
fillColor: fillColor,
|
||
|
focusColor: focusColor,
|
||
|
iconColor: iconColor,
|
||
|
prefixIconColor: prefixIconColor,
|
||
|
suffixIconColor: suffixIconColor,
|
||
|
|
||
|
///
|
||
|
labelStyle: buildTextStyle(
|
||
|
color: labeledColor,
|
||
|
fontSize: 15,
|
||
|
),
|
||
|
prefixStyle: buildTextStyle(
|
||
|
color: Colors.white,
|
||
|
),
|
||
|
suffixStyle: buildTextStyle(
|
||
|
color: Colors.white,
|
||
|
),
|
||
|
errorStyle: buildTextStyle(
|
||
|
fontSize: 12,
|
||
|
color: const Color(0xffC4C4C4),
|
||
|
),
|
||
|
hintStyle: buildTextStyle(
|
||
|
color: const Color(0xffD7D7D7),
|
||
|
fontSize: 19,
|
||
|
),
|
||
|
),
|
||
|
style: buildTextStyle(
|
||
|
fontSize: 20,
|
||
|
color: inputColor ?? Colors.white,
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|