如何在 Flutter 中发送 DropDownButton 值,例如 TextEditingController for TextFormField
我正在尝试将 DropDownButton 选定的值发送到 EmailJS。我正在使用 TextEditingController 作为 TextFormField,它工作正常,并且值由 EmailJS 获取。如何发送可以在 Flutter 中使用的控制器的 DropDownButton 值。
Padding(
padding: EdgeInsets.all(20),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(0),
border: Border.all(
color: Colors.black12,
width: 1
),
),
child: Padding(
padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
child: DropdownButton<String>(
hint: Text('Select Service',
style: TextStyle(
fontFamily:'D-Din',
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.black45
),
),
value: dropdownValue,
iconSize: 30,
icon: Icon(
Icons.arrow_drop_down,
color: Colors.black45,
),
isExpanded: true,
items: items.map(buildMenuItem).toList(),
onChanged: (value) => setState(() => this.dropdownValue = value),
),
),
),
),
我必须发送这些值。
I'm trying to send the DropDownButton selected values to EmailJS. I'm using TextEditingController for TextFormField and it's working fine and the values taken by EmailJS. How I can send the DropDownButton values whichcontroller I can use in Flutter.
Padding(
padding: EdgeInsets.all(20),
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(0),
border: Border.all(
color: Colors.black12,
width: 1
),
),
child: Padding(
padding: EdgeInsets.fromLTRB(10, 5, 10, 5),
child: DropdownButton<String>(
hint: Text('Select Service',
style: TextStyle(
fontFamily:'D-Din',
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.black45
),
),
value: dropdownValue,
iconSize: 30,
icon: Icon(
Icons.arrow_drop_down,
color: Colors.black45,
),
isExpanded: true,
items: items.map(buildMenuItem).toList(),
onChanged: (value) => setState(() => this.dropdownValue = value),
),
),
),
),
I have to send the values.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我尝试了这种方式,现在正在发送数据。
我在onpressed中用这种方式传递了drop box的值。
并调用类变量。
就是这样。
I tried this way and It's sending data now.
I pass the value of the drop box with this way in onpressed.
and call the class variable.
that's it.