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: