-
Notifications
You must be signed in to change notification settings - Fork 13
/
auth_text_field.dart
54 lines (51 loc) · 1.63 KB
/
auth_text_field.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import 'package:flutter/material.dart';
class AuthTextField extends StatelessWidget {
final String hint;
final ValueChanged<String> onChanged;
final TextInputType keyboardType;
final bool isPasswordField;
final bool isRequiredField;
final String? error;
final EdgeInsets padding;
const AuthTextField({
Key? key,
this.hint = '',
required this.onChanged,
required this.keyboardType,
this.isPasswordField = false,
this.isRequiredField = false,
this.error,
this.padding = const EdgeInsets.all(0),
}) : super(key: key);
@override
Widget build(BuildContext context) {
UnderlineInputBorder border =
const UnderlineInputBorder(borderSide: BorderSide(color: Colors.blueAccent, width: 2));
UnderlineInputBorder errorBorder =
const UnderlineInputBorder(borderSide: BorderSide(color: Colors.redAccent, width: 2));
return Padding(
padding: padding,
child: TextFormField(
keyboardType: keyboardType,
decoration: InputDecoration(
fillColor: Colors.white,
contentPadding: const EdgeInsets.symmetric(horizontal: 12),
filled: true,
hintText: isRequiredField ? '$hint*' : hint,
border: border,
disabledBorder: border,
enabledBorder: border,
errorBorder: errorBorder,
focusedErrorBorder: errorBorder,
errorText: error,
floatingLabelBehavior: FloatingLabelBehavior.never,
),
autocorrect: false,
textInputAction: TextInputAction.done,
obscureText: isPasswordField,
maxLines: 1,
onChanged: onChanged,
),
);
}
}