Blame view

lib/common/widgets/textfield_customer_widget.dart 2.08 KB
4bf67b91   liangchengyou   feat:设置密码
1
2
3
4
  import 'package:flutter/material.dart';
  import 'package:flutter_screenutil/flutter_screenutil.dart';
  import 'package:wow_english/common/extension/string_extension.dart';
  
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
5
6
  class TextFieldCustomerWidget extends StatefulWidget {
    const TextFieldCustomerWidget({super.key,
4bf67b91   liangchengyou   feat:设置密码
7
8
9
10
11
12
13
14
15
      this.controller,
      this.hitStyle,
      this.textStyle,
      this.bgImageName,
      this.hitText,
      this.width,
      this.height,
      this.textAlign,
      this.textInputType,
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
16
      this.obscureText,
4bf67b91   liangchengyou   feat:设置密码
17
18
19
20
21
22
23
24
25
26
27
28
      this.onChangeValue
    });
  
    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;
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
29
    final bool? obscureText;
4bf67b91   liangchengyou   feat:设置密码
30
31
32
33
    final Function(String value)? onChangeValue;
  
    @override
    State<StatefulWidget> createState() {
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
34
      return _TextFieldCustomerWidgetState();
4bf67b91   liangchengyou   feat:设置密码
35
36
37
    }
  }
  
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
38
  class _TextFieldCustomerWidgetState extends State<TextFieldCustomerWidget> {
4bf67b91   liangchengyou   feat:设置密码
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
    @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(
          controller: widget.controller,
          textAlign: widget.textAlign??TextAlign.center,
          textInputAction: TextInputAction.done,
          keyboardType: widget.textInputType,
1d5315dd   liangchengyou   feat:添加字体,调整文件结构
58
          obscureText: widget.obscureText?? false,
4bf67b91   liangchengyou   feat:设置密码
59
60
61
          decoration: InputDecoration(
            hintText: widget.hitText??'',
            border: InputBorder.none,
f0d56772   liangchengyou   feat:更新尺寸适配
62
63
64
            hintStyle: widget.hitStyle??  TextStyle(
              fontSize: 16.sp,
              color:const Color(0xFF999999)
4bf67b91   liangchengyou   feat:设置密码
65
66
            )
          ),
f0d56772   liangchengyou   feat:更新尺寸适配
67
68
69
          style: widget.textStyle??  TextStyle(
            color: const Color(0xFF333333),
            fontSize: 16.sp,
4bf67b91   liangchengyou   feat:设置密码
70
71
72
73
74
75
          ),
          onChanged: widget.onChangeValue,
        ),
      );
    }
  }