【发布时间】:2021-01-29 15:02:03
【问题描述】:
根据图像,我必须根据我的要求从所需字段中获取所有值,即从 TextFormField、CustomRadioButton & 以及 patient age 中获取。单击提交按钮时,我必须获取这些值,以便我可以通过提供者传递它们。
由于我是 Flutter 的新手,我可以从 TextFormField 中获取值,但无法从两者的其余部分中获取值。
下面是我的用户界面。
下面是CustomRadioButton的代码
Container(
width: 200,
child: CustomRadioButton(
customShape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(10)),
elevation: 0,
absoluteZeroSpacing: false,
unSelectedColor: Theme.of(context).canvasColor,
buttonLables: [
'Male',
'Female',
],
buttonValues: [
"MALE",
"FEMALE",
],
buttonTextStyle: ButtonTextStyle(
textStyle: TextStyle(fontSize: 10)),
radioButtonValue: (value) {
print(value);
},
width: 80,
height: 60,
enableShape: true,
selectedBorderColor: Colors.green,
unSelectedBorderColor: Color(0xFFD0D7EB),
selectedColor: Colors.green,
),
),
-
对于年龄选择器(/不知道我是否正确,因为我刚刚硬编码了文本 12,但希望
+和-应该可以工作。/)Container( width: 100.0, height: 55.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(10.0), border: Border.all( color: Color(0xFFD0D7EB), ) ), child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ InkWell( onTap: () {}, child: Container( height: 25.0, width: 25.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(7.0), border: Border.all( color: Color(0xFFD0D7EB), ) ), child: Center( child: Icon( Icons.remove, color: Colors.black, size: 20.0, ), ), ), ), Text( '12', style: TextStyle( fontFamily: 'Montserrat', fontSize: 20.0, color: Colors.black), ), InkWell( onTap: () {}, child: Container( height: 25.0, width: 25.0, decoration: BoxDecoration( borderRadius: BorderRadius.circular(7.0), border: Border.all( color: Color(0xFFD0D7EB), ) ), child: Center( child: Icon( Icons.add, color: Colors.black, size: 20.0, ), ), ), ) ], ), ) ], ), SizedBox(height: 80), Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Container( height: 40, child: RaisedButton( color: Color(0xFF888DA1), child: Text('Submit', style: TextStyle(fontFamily: 'Poppins-Regular', fontSize: 14, color: Colors.white)), onPressed: (){ submit(); } ), ), ], -
这是我将获取这些值的函数
提交() 异步{ 打印(名称控制器。文本); }
请帮助我如何做到这一点!
【问题讨论】:
-
看起来您正在使用静态值
Text( '12',来表示年龄 -
不,现在我只是对其进行了硬编码,但实际上可以通过点击
+或-来选择年龄。您能否告诉我如何获取这些值以及如何成功操作+和-。请帮助我@Shubham Narkhede。 -
是的,只要一分钟就会给出答案
-
请检查我的回答,如果这对您有用,请将其标记为真实并进行投票