【发布时间】:2021-11-08 23:11:44
【问题描述】:
当我编写此代码时,
TextFormField(
cursorRadius: Radius.circular(26),
cursorColor: Colors.green,
onChanged: onTextInChange,
textInputAction: TextInputAction.search,
decoration: const InputDecoration(
border: UnderlineInputBorder(),
labelText: texts.toForm[0],
hintText: texts.toForm[1],
helperText: texts.toForm[2],
labelStyle: TextStyle(fontSize: 18),
hintStyle: TextStyle(fontSize: 18),
),
)
而我的 Texts 类是这样的,
class Texts{
let toForm = ['Enter Your Name', 'John Fernando', 'This is a Helper Text'];
}
我收到一个错误,
Invalid constant value.dart(invalid_constant)
这些 helperText、hintText、helperText 需要常量字符串,但我想使用 List 将它们传递给这样的类,不要直接指定值。
那么,我该怎么办?
请帮帮我!我是 Flutter 和 Dart 的新手!!!
【问题讨论】:
标签: flutter dart type-conversion constants var