At least one clipboard data variant must be provided
Summary
#The ClipboardData constructor's text argument is no longer nullable.
Code that provides null to the text argument must be migrated to provide
an empty string ''.
Context
#In preparation for supporting multiple clipboard data variants, the
ClipboardData constructor now requires that at least one data variant is
provided.
Previously, platforms were inconsistent in how they handled null.
The behavior is now consistent across platforms. If you are interested
in the low-level details, see PR 122446.
Description of change
#The ClipboardData constructor's text argument is no longer nullable.
Migration guide
#To reset the text clipboard, use an empty string '' instead of null.
Code before migration:
void resetClipboard() {
Clipboard.setData(ClipboardData(text: null));
}Code after migration:
void resetClipboard() {
Clipboard.setData(ClipboardData(text: ''));
}Timeline
#Landed in version: 3.10.0-9.0.pre
In stable release: 3.10.0
References
#API documentation:
Relevant PRs:
除非另有说明,本文档之所提及适用于 Flutter 的最新稳定版本,本页面最后更新时间: 2024-04-04。 查看文档源码 或者 为本页面内容提出建议.