美文网首页
flutter 输入框2024-01-03

flutter 输入框2024-01-03

作者: iOS打怪升级 | 来源:发表于2024-01-02 18:32 被阅读0次
    class HQConfirmExchangeInfoSection extends StatefulWidget {
      final Function(String? results)? callBack;
    
      const HQConfirmExchangeInfoSection({super.key, this.callBack});
    
      @override
      HQConfirmExchangeInfoSectionState createState() =>
          HQConfirmExchangeInfoSectionState();
    }
    
    class HQConfirmExchangeInfoSectionState
        extends State<HQConfirmExchangeInfoSection> {
      final TextEditingController _phoneController = TextEditingController();
    
      Function(String? results)? get callBack {
        return widget.callBack;
      }
    
      @override
      Widget build(BuildContext context) {
        // TODO: implement build
        return Container(
          height: 76,
          margin: const EdgeInsets.only(left: 16, right: 16, top: 8, bottom: 8),
          padding: const EdgeInsets.only(left: 16, right: 0),
          color: Colors.white,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              const Text(
                '手机号码',
                style: TextStyle(color: Color(0xFF2A2C34), fontSize: 15),
              ),
              const SizedBox(
                width: 10,
              ),
              Expanded(
                child: TextField(
                  controller: _phoneController,
                  style: const TextStyle(color: Color(0xff2A2C34), fontSize: 14),
                  decoration: InputDecoration(
                    hintText: '请输入兑换卡券手机号码',
                    hintStyle: TextStyle(
                      color: const Color(0xFF2A2C34).withOpacity(0.2),
                      fontSize: 14,
                    ),
                    focusedBorder: InputBorder.none,
                    border:InputBorder.none,
                  ),
                  onChanged: (text) {
                    if (callBack != null) {
                      callBack!(text);
                    }
                  },
                ),
              ),
              TextButton(onPressed: (){
    /// 失去焦点
                FocusScope.of(context).unfocus();
              }, style: TextButton.styleFrom(
                padding: EdgeInsets.zero,
    
              ), child: const Text('完成', style: TextStyle(color: Color(0xff3A6EE9), fontSize: 16),)),
            ],
          ),
        );
        throw UnimplementedError();
      }
    }
    

    相关文章

      网友评论

          本文标题:flutter 输入框2024-01-03

          本文链接:https://www.haomeiwen.com/subject/cuzpndtx.html