gpt4 book ai didi

flutter - TextFormField根据单选按钮启用/禁用选中的Flutter

转载 作者:行者123 更新时间:2023-12-03 03:25:42 25 4
gpt4 key购买 nike

在flutter中选中后,如何根据单选按钮启用/禁用TextFormField

      new Text('Allpages? :', style: new TextStyle(height: 1.0, fontSize: 15.2, fontWeight: FontWeight.bold,)),
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Radio(
value: 0,
groupValue: _printAllValue,
onChanged: _setPrintAllValue,
),
new Text('Yes'),
new Radio(
value: 1,
groupValue: _printAllValue,
onChanged: _setPrintAllValue,
),
new Text('No'),
],
),
new Padding(padding: new EdgeInsets.all(5.0)),
new Text('Start and End pages :', style: new TextStyle(height: 1.0, fontSize: 15.2, fontWeight: FontWeight.bold,)),
new Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
new Container(
width: 200,
child: new TextFormField(
style: TextStyle(color: Colors.black87),
textInputAction: TextInputAction.done,
keyboardType: TextInputType.phone,
decoration: InputDecoration(
labelText: 'Start Page',
),
),

),
new Container(
width: 200,
child: new TextFormField(
style: TextStyle(color: Colors.black87),
textInputAction: TextInputAction.done,
keyboardType: TextInputType.phone,
decoration: InputDecoration(
labelText: 'End Page',
),
),

),
],
),

new Padding(padding: new EdgeInsets.all(10.0)),

我需要先检查“ No”单选按钮,然后将“起始页”,“结束页”设为 激活,并选中 yes单选按钮时,将 停用

最佳答案

您可以将TextFormField包装在AbsorbPointer中,并处理absorb属性,例如:

bool _disable = false; // set this to false initially

AbsorbPointer(
absorbing: _disable, // true makes TextFormField disabled and vice-versa
child: TextFormField(),
)

每当您要禁用以上字段时,都可以更改其属性,并实际上从 Radio中获取值并将其分配给 _disable
编辑:

TextFormField中有一个属性,您可以更改它
TextFormField(
enabled: !_disable, // set to false to disable it.
),

关于flutter - TextFormField根据单选按钮启用/禁用选中的Flutter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57747067/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com