textfield_customer_widget.dart
2.21 KB
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:wow_english/common/extension/string_extension.dart';
class TextFieldCustomerWidget extends StatefulWidget {
const TextFieldCustomerWidget({
super.key,
this.controller,
this.hitStyle,
this.textStyle,
this.bgImageName,
this.hitText,
this.width,
this.height,
this.textAlign,
this.textInputType,
this.obscureText,
this.onChangeValue,
this.inputFormatters,
});
final TextEditingController? controller;
final TextStyle? hitStyle;
final TextStyle? textStyle;
final String? bgImageName;
final String? hitText;
final double? width;
final double? height;
final TextAlign? textAlign;
final TextInputType? textInputType;
final bool? obscureText;
final Function(String value)? onChangeValue;
final List<TextInputFormatter>? inputFormatters;
@override
State<StatefulWidget> createState() {
return _TextFieldCustomerWidgetState();
}
}
class _TextFieldCustomerWidgetState extends State<TextFieldCustomerWidget> {
@override
Widget build(BuildContext context) {
return Container(
height: widget.height ?? 45.h,
width: widget.width ?? double.infinity,
alignment: Alignment.center,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('${widget.bgImageName}'.assetPng),
fit: BoxFit.fill,
)),
child: TextField(
inputFormatters: widget.inputFormatters,
controller: widget.controller,
textAlign: widget.textAlign ?? TextAlign.center,
textInputAction: TextInputAction.done,
keyboardType: widget.textInputType,
obscureText: widget.obscureText ?? false,
decoration: InputDecoration(
hintText: widget.hitText ?? '',
border: InputBorder.none,
hintStyle: widget.hitStyle ?? TextStyle(fontSize: 16.sp, color: const Color(0xFF999999))),
style: widget.textStyle ??
TextStyle(
color: const Color(0xFF333333),
fontSize: 16.sp,
),
onChanged: widget.onChangeValue,
),
);
}
}