New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Clipboard] Assert at least one clipboard data variant is provided #122446
[Clipboard] Assert at least one clipboard data variant is provided #122446
Conversation
4a5b89a
to
45518bb
Compare
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I don't like the assert, wouldn't something like "text must not be null" be simpler? There are no other variants right now, it isn't clear. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@bernaferrari Thanks for the feedback, I agree that the previous assertion message was unclear. This should be addressed now, let me know if you have additional comments! |
Maaaaybe I would mention in the comment "eventually with unions this won't be nullable anymore" or something like this, because in a few years when someone implements union in Dart, someone could possibly just search the codebase and update. Maybe. Just an idea. |
@bernaferrari The clipboard can contain different content for different formats. |
That's fair.. I was thinking text only. |
d251c0a
to
629e72f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great - and thanks for the detailed notes on the current broken behaviour when this is null. If you haven't already, make sure this gets added to the release notes.
Flutter behaves unexpectedly if you set your clipboard text to null: 1. Android and iOS will set your clipboard content to the text "null". 2. Linux and web throws 3. Windows crashes Flutter will be updated to disallow setting the clipboard text to null: flutter/flutter#122446 Part of flutter/flutter#121976
Flutter behaves unexpectedly if you set your clipboard text to null: 1. Android and iOS will set your clipboard content to the text "null". 2. Linux and web throws 3. Windows crashes Flutter will be updated to disallow setting the clipboard text to null: flutter/flutter#122446 Part of flutter/flutter#121976
This change makes the clipboard require at least one clipboard data variant. Today, this effectively makes `ClipboardData.text` required as it is the only data variant supported by `Clipboard`. This is a breaking change. Part of flutter#121976
629e72f
to
8117593
Compare
#122446 was a breaking change in Flutter 3.10 that made the `ClipboardData` constructor's `text` argument a required non-nullable argument. This leverages `dart fix`'s new automatic migration to, well, automatically migrate affected users. Manual migration docs: https://docs.flutter.dev/release/breaking-changes/clipboard-data-required Follow-up to #122446 Part of #121976
This change makes the clipboard require at least one clipboard data variant. Today, this effectively makes
ClipboardData.text
required as it is the only data variant supported byClipboard
. This is a breaking change.Part of #121976
Background
Currently the different platforms behave unexpectedly if you set your clipboard text to
null
:"null"
.In other words, customers who set their clipboard to
null
today are broken. Instead, they should set their clipboard's text to the empty string""
.Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.