flutter - Dart 动态访问 getter
问题描述
Flutter中生成AppLocalizations
的getter有很多
final appLocalizations = AppLocalizations.of(context)!;
print(appLocalizations.helloWorld);
我有一个用例,getter 键存储在 a 中List<String>
,我需要翻译它们
const key = 'helloWorld';
print(appLocalizations[key]);
如何通过String
变量访问 getter key
?
解决方案
不幸的是,您目前还不能这样做。不久前我提交了一个功能请求,但他们似乎对此并不感兴趣。
推荐阅读
- java - Spring Boot ModelMapper - 无会话
- numpy - 谁能解释一下这个代码输出
- ruby-on-rails - rails app current_user 方法在生产中不起作用
- c++ - (C/C++) 在同一行初始化并返回数组
- c# - 在 c# 中编码为 Php 不同的结果
- javascript - jQuery 或原生 JS 替换整个元素 (div),包括其 id、类和数据
- javascript - 为什么我的 Ajax 回调处理得太快了?
- android - 如何从具有不同数据的通知中意图不同的活动?
- r - 在 R 中使用 REGEX 将值中的特定字符串提取为新列?
- python - jupyter notebook 无法导入keras