# At least one clipboard data variant must be provided

> In preparation for supporting multiple clipboard data variants, at least one clipboard data variant must be provided.




:::important
These breaking change docs are accurate, as of the release
under which they are published. Over time, the
workarounds described here might become inaccurate.
We don't, in general, keep these breaking change docs up
to date as of each release.

这些破坏性改动文档的准确性仅限于其发布时对应的版本。
随着时间的推移，文档中描述的方案可能会逐渐失效。
通常情况下，我们不会在每次发布新版本时都对这些文档进行同步更新。

The [breaking change index file](/release/breaking-changes)
lists the docs created for each release.

[破坏性改动列表](/release/breaking-changes) 
列出了每个版本的文档。

:::


## 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:

```dart
void resetClipboard() {
  Clipboard.setData(ClipboardData(text: null));
}
```

Code after migration:

```dart
void resetClipboard() {
  Clipboard.setData(ClipboardData(text: ''));
}
```

## Timeline

Landed in version: 3.10.0-9.0.pre<br>
In stable release: 3.10.0

## References

API documentation:

* [`Clipboard.setData`][]
* [`ClipboardData constructor`][]

Relevant PRs:

* [Assert at least one clipboard data variant is provided][]

[`ClipboardData constructor`]: https://api.flutter-io.cn/flutter/services/ClipboardData/ClipboardData.html
[`Clipboard.setData`]: https://api.flutter-io.cn/flutter/services/Clipboard/setData.html
[PR 122446]: https://github.com/flutter/flutter/pull/122446
[Assert at least one clipboard data variant is provided]: https://github.com/flutter/flutter/pull/122446

