material 本地化字符串迁移指南
概述
#ReorderableListView 的本地化字符串已从 material 本地化迁移到 widgets 本地化。这些字符串在 material 本地化中已弃用。
背景
#ReorderableListView 使用这些字符串来注释其语义操作。为了将相同的注释应用于 ReorderableList 和 SliverReorderableList,它们需要从 widgets 库访问这些字符串。
变更说明
#MaterialLocalizations 中用于 reorderItemToStart、reorderItemToEnd、reorderItemUp、reorderItemDown、reorderItemLeft 和 reorderItemRight 的字符串已被弃用,并被 WidgetsLocalizations 中的相同字符串所取代。
迁移指南
#如果您在代码中使用这些字符串,可以从 WidgetsLocalizations 中访问它们。
迁移前的代码
dart
MaterialLocalizations.of(context).reorderItemToStart;迁移后的代码
dart
WidgetsLocalizations.of(context).reorderItemToStart;如果您重写了 MaterialLocalizations 或 WidgetsLocalizations,请确保从 MaterialLocalizations 子类中移除翻译,并将它们移至 WidgetsLocalizations 子类。
迁移前的代码
dart
class MaterialLocalizationsMyLanguage extends MaterialLocalizationsEn {
// ...
@override
String get reorderItemRight => 'my translation';
}迁移后的代码
dart
class MaterialLocalizationsMyLanguage extends MaterialLocalizationsEn {
// ...
}
class WidgetsLocalizationsMyLanguage extends WidgetsLocalizationsEn {
// ...
@override
String get reorderItemRight => 'my translation';
}时间线
#已登陆版本:v3.10.0-2.0.pre
在稳定版中发布: 3.13.0
参考资料
#相关 PR
- PR 124711: 弃用 material_localizations 中 ReorderableList 的字符串。