【发布时间】:2021-02-03 18:55:38
【问题描述】:
我尝试将 textField 包装成一行并向该行添加一个容器,但它会引发错误,并且表单的其余部分不会呈现。 并且使用 textField 的前缀属性也不起作用,因为当按下 textField 时会显示容器,但我希望即使 textField 不活动也能看到它。
this is the required UI for the mobile no. field I'm trying to build
【问题讨论】:
我尝试将 textField 包装成一行并向该行添加一个容器,但它会引发错误,并且表单的其余部分不会呈现。 并且使用 textField 的前缀属性也不起作用,因为当按下 textField 时会显示容器,但我希望即使 textField 不活动也能看到它。
this is the required UI for the mobile no. field I'm trying to build
【问题讨论】:
Container(
decoration: BoxDecoration(
color: Colors.grey[200],
borderRadius: BorderRadius.circular(8),
),
child: Row(
children: [
Container(
height: 50,
alignment: Alignment.center,
padding: const EdgeInsets.symmetric(
horizontal: 8,
),
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8),
bottomLeft: Radius.circular(8),
),
),
child: Text(
"+91",
style: TextStyle(
color: Colors.white,
),
),
),
Expanded(
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 12,
),
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: "Mobile No."
),
),
),
)
],
),
)
结果:
【讨论】: