flutter - Flutter_Translate:方法调用不是常量表达式
问题描述
如何解决这个问题。非常感谢。
import 'package:flutter_translate/flutter_translate.dart';
class TabViewerPopupMenuActions {
static const String NEW_TAB = translate(
'options.new_tab'); //ERROR: Const variables must be initialized with a constant value.
static const List<String> choices = <String>[
NEW_TAB
];
}
我尝试删除 const
class TabViewerPopupMenuActions {
static String NEW_TAB = translate(
'options.new_tab');
static List<String> choices = <String>[
NEW_TAB
];
}
但开关盒错误
switch (choice) {
case TabViewerPopupMenuActions.NEW_TAB
错误:案例表达式必须是常量
解决方案
推荐阅读
- javascript - 在自定义函数中链接中间件函数
- javascript - if 和 draw 语句的顺序
- ansible - 在 Ansible 中查找文件名并保存到文件
- react-native - 如何处理嵌套在 createDrawerNavigator 中的 createStackNavigator 屏幕的路由?
- python - 如何从文件中获取链接并在python中循环它?
- dart - 是否有 Dart 函数来转换 List
加倍? - flutter - 使用 setState() 在应用程序中保持用户登录
- c# - 使用 c#/WPF/livecharts。如何在 SeriesCollection 中设置单个项目的可见性?
- javascript - 如何在画布中查找和替换图像的颜色?
- cqrs - 使用 EventSourcing 和大量事件进行聚合设计