Aidra Connect 10.0.2+16
Aidra Connect Mobile Application
Loading...
Searching...
No Matches
custom_text_form_field.dart
Go to the documentation of this file.
1import 'package:flutter/material.dart';
2import 'package:flutter/services.dart';
3import 'package:flutter_screenutil/flutter_screenutil.dart';
4
5class CustomTextFormField extends StatelessWidget {
7 super.key,
8 required this.hintText,
9 required this.controller,
10 this.suffix,
11 this.focusNode,
12 this.validator,
13 this.isObscure = false,
14 this.inputType,
15 this.maxLines = 1,
16 this.padding,
17 this.fillColor,
18 this.labelText,
19 this.inputFormatters,
20 this.onChanged,
21 });
22
23 final TextEditingController controller;
24 final String hintText;
25 final Widget? suffix;
26 final FocusNode? focusNode;
27 final String? Function(String?)? validator;
28 final Function(String)? onChanged;
29 final bool isObscure;
30 final TextInputType? inputType;
31 final int? maxLines;
32 final EdgeInsets? padding;
33 final Color? fillColor;
34 final String? labelText;
35 final List<TextInputFormatter>? inputFormatters;
36
37 @override
38 Widget build(BuildContext context) {
39 return TextFormField(
40 onChanged: onChanged,
42 keyboardType: inputType,
44 obscureText: isObscure,
47 validator: validator,
48 style: Theme.of(context).textTheme.bodySmall,
49 decoration: InputDecoration(
50 filled: true,
51 fillColor: fillColor ?? Theme.of(context).colorScheme.surface,
53 hintStyle: Theme.of(context).textTheme.bodySmall?.copyWith(
54 color: Theme.of(context).hintColor,
55 ),
57 floatingLabelBehavior: FloatingLabelBehavior.auto,
58 suffixIcon: suffix,
59 contentPadding: padding ??
60 EdgeInsetsDirectional.symmetric(
61 vertical: 18.sp,
62 horizontal: 15.sp,
63 ),
64 enabledBorder: OutlineInputBorder(
65 borderRadius: BorderRadius.circular(12.r),
66 borderSide: BorderSide(
67 color: Theme.of(context).hintColor.withOpacity(.11),
68 width: 0.5,
69 ),
70 ),
71 focusedBorder: OutlineInputBorder(
72 borderRadius: BorderRadius.circular(12.r),
73 borderSide: BorderSide(
74 color: Theme.of(context).primaryColor,
75 width: 1,
76 ),
77 ),
78 errorBorder: OutlineInputBorder(
79 borderRadius: BorderRadius.circular(12.r),
80 borderSide: BorderSide(
81 color: Theme.of(context).colorScheme.error,
82 width: 0.5,
83 ),
84 ),
85 focusedErrorBorder: OutlineInputBorder(
86 borderRadius: BorderRadius.circular(12.r),
87 borderSide: BorderSide(
88 color: Theme.of(context).colorScheme.error,
89 width: 1,
90 ),
91 ),
92 ),
93 );
94 }
95}
final List< TextInputFormatter > inputFormatters
final Function(String)? onChanged
final TextEditingController controller
override Widget build(BuildContext context)
const CustomTextFormField({ super.key, required this.hintText, required this.controller, this.suffix, this.focusNode, this.validator, this.isObscure=false, this.inputType, this.maxLines=1, this.padding, this.fillColor, this.labelText, this.inputFormatters, this.onChanged, })
final TextInputType inputType
final String Function(String?)? validator