我在我的应用程序上使用intl进行翻译,当我在hintText上使用翻译时,我遇到了一个问题,我得到了这个错误:
常量创建的
参数必须是常量表达式
示例代码:
new TextField(
decoration: const InputDecoration(
contentPadding: EdgeInsets.only(top: 16.0),
hintText: AppLocalizations.of(context).search_message, // Variable
border: InputBorder.none,
),
keyboardType: TextInputType.text,
textInputAction: TextInputAction.search,
style: new TextStyle(
fontSize: 16.0,
color: Colors.black
)
)
我知道这个错误是因为我使用了AppLocalizations.of(context).search_message,(它是变量),但问题是:我该如何翻译这个hintText?
https://stackoverflow.com/questions/52016110
复制相似问题