gpt4 book ai didi

flutter - InputDecoration errorText 必须是常量

转载 作者:IT老高 更新时间:2023-10-28 12:38:42 25 4
gpt4 key购买 nike

[dart] Invalid constant value.[dart] Arguments of a constant creation must be constant expressions.

我想做 DropdownButton ,但是 errorText 只接受常量变量。

[dart] Invalid constant value.[dart] Arguments of a constant creation must be constant expressions.

Constant variable means I cannot replace with other text.

Maybe any other way to make DropdownButton validation?

String errorGender = null;

var _inputGender = InputDecorator(
decoration: const InputDecoration(labelText: 'Gender', errorText: errorGender),
isEmpty: data['gender'] == null,
child: DropdownButtonHideUnderline(
child: ButtonTheme(
alignedDropdown: true,
child: DropdownButton(
isDense: true,
value: data['gender'],
onChanged: (value) => setState(() => data['gender'] = value),
items: _gender.map((value) {
return DropdownMenuItem(
value: value,
child: Text(value[0].toUpperCase() + value.substring(1)),
);
}).toList()
)
)
)
);

最佳答案

删除 InputDecoration

之前的 const
decoration: InputDecoration(labelText: 'Gender', errorText: errorGender)

关于flutter - InputDecoration errorText 必须是常量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52718061/

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