flutter输入框宽度跟随文本长度变化

该文描述了一个Flutter应用中的界面组件设计,包含一个白色的Container,内部有文字、间距、边框和圆角。Row中有一个Column显示退款信息,一个扩展的Container,以及一个右对齐的货币符号。此外,还展示了一个受约束的TextField,用于输入退款金额,限制为最小8到最大屏幕宽度的38%,并配置了输入格式和风格。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Container(
            padding: EdgeInsets.all(20.w),
            margin: EdgeInsets.only(top: 20.w),
            decoration: BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.circular(10)
            ),
            child: Row(
              children: [
                Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(S.current.refundAmount,style: TextStyle(fontSize: 28.sp,fontWeight: FontWeight.w600),),
                    SizedBox(height: 20.w,),
                    Text('${S.current.modifiable}${S.current.most}¥99.00',
                      style: TextStyle(color: JadeColors.grey_7,fontSize: 20.sp),),
                  ],
                ),
                Expanded(child: Container()),
                Container(
                  padding: EdgeInsets.only(bottom: 10.w),
                  child: Text('¥',style: TextStyle(fontSize: 28.sp,color: JadeColors.claret,),),
                ),
                //ConstrainedBox中的就是收缩包裹的TextField
                ConstrainedBox(
                  constraints: BoxConstraints(minWidth: 8.w,maxWidth: Utils().screenWidth(context)*0.38),
                  child: IntrinsicWidth(
                    child: TextField(
                      textAlign: TextAlign.right,
                      // controller: _amountTextEditingController,
                      // focusNode: _amountFocusNode,
                      style: TextStyle(
                          fontSize: 30.sp,
                          color: JadeColors.claret,
                          fontWeight: FontWeight.w600),
                      keyboardType: TextInputType.number,
                      textInputAction: TextInputAction.next,
                      maxLines: 1,
                      decoration: InputDecoration(
                        filled: true,
                        fillColor: Colors.white,
                        contentPadding: EdgeInsets.only(
                            left: 4.w, right: 4.w, top: 10.w, bottom: 10.w),
                        alignLabelWithHint: false,
                        border: OutlineInputBorder(
                            borderSide: BorderSide.none,
                            borderRadius: BorderRadius.circular(8.w)),
                        focusedBorder: OutlineInputBorder(
                            borderSide: BorderSide.none,
                            borderRadius: BorderRadius.circular(8.w)),
                      ),
                      cursorColor: JadeColors.grey,
                      onEditingComplete: () {
                      //  FocusScope.of(context).requestFocus(_remarkFocusNode);
                      },
                    ),
                  ),
                )
              ],
            ),
          ),
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值