我在我的应用程序上使用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
)
)
Run Code Online (Sandbox Code Playgroud)
我知道错误是因为我使用AppLocalizations.of(context).search_message,(这是可变的)但问题是:我如何翻译这个hintText?