跳至主要內容

將 Chips 的 useDeleteButtonTooltip 遷移至 deleteButtonTooltipMessage

摘要

#

使用任何具有刪除按鈕的晶片 (chip) 的 useDeleteButtonTooltip 會產生棄用警告,或在參考時不再存在。這包括 ChipInputChipRawChip 小工具。

背景

#

ChipInputChipRawChip 小工具的 useDeleteButtonTooltip 已棄用,改用 deleteButtonTooltipMessage,因為後者可用於停用晶片的刪除按鈕的工具提示。

變更說明

#

deleteButtonTooltipMessage 屬性為晶片小工具 (chip widgets) 的刪除按鈕上的工具提示提供訊息。隨後,進行了一項變更,將此屬性設為空字串即可停用工具提示。

為了避免 API 的冗餘,這項變更已棄用 useDeleteButtonTooltip,該屬性最初就是為了這個功能而引入的。如果您的確停用了工具提示,則可以使用 Flutter 修復工具 協助您將現有程式碼從 useDeleteButtonTooltip 遷移到 deleteButtonTooltipMessage

遷移指南

#

預設情況下,刪除按鈕的工具提示永遠啟用。若要明確停用工具提示,請將空字串提供給 deleteButtonTooltipMessage 屬性。以下程式碼片段顯示遷移變更,適用於 ChipInputChipRawChip 小工具。

遷移前的程式碼

dart
Chip(
  label: const Text('Disabled delete button tooltip'),
  onDeleted: _handleDeleteChip,
  useDeleteButtonTooltip: false,
);

RawChip(
  label: const Text('Enabled delete button tooltip'),
  onDeleted: _handleDeleteChip,
  useDeleteButtonTooltip: true,
);

遷移後的程式碼

dart
Chip(
  label: const Text('Disabled delete button tooltip'),
  onDeleted: _handleDeleteChip,
  deleteButtonTooltipMessage: '',
);

RawChip(
  label: const Text('Enabled delete button tooltip'),
  onDeleted: _handleDeleteChip,
);

時程表

#

已於版本中實作:2.11.0-0.1.pre
於穩定版本中發佈:3.0.0

參考資料

#

API 文件

相關 PR