概述

#

ReorderableListView 的本地化字串已從 material 本地化遷移到 widgets 本地化。這些字串在 material 本地化中已棄用。

背景

#

ReorderableListView 使用這些字串來註釋其語義操作。為了將相同的註釋應用於 ReorderableListSliverReorderableList,它們需要從 widgets 庫訪問這些字串。

變更說明

#

MaterialLocalizations 中用於 reorderItemToStartreorderItemToEndreorderItemUpreorderItemDownreorderItemLeftreorderItemRight 的字串已被棄用,並被 WidgetsLocalizations 中的相同字串所取代。

遷移指南

#

如果您在程式碼中使用這些字串,可以從 WidgetsLocalizations 中訪問它們。

遷移前的程式碼

dart
MaterialLocalizations.of(context).reorderItemToStart;

遷移後的程式碼

dart
WidgetsLocalizations.of(context).reorderItemToStart;

如果您重寫了 MaterialLocalizationsWidgetsLocalizations,請確保從 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 的字串。