-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[plugin_platform_interface] Don't use const Object as a token #2417
Conversation
@@ -1,3 +1,7 @@ | |||
## 1.0.5 | |||
|
|||
* Make the PlatformInterface _token non const (as const Object's are not unique). |
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.
fix formatting
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.
You can also check and throw an exception if token == const Object()
since this could be a common mistake.
Yes, I mentioned this in the PR description, I'll followup in a separate PR as we should make sure existing plugins are already updated (I think it's early enough to assume the currently only first party plugins are using this) |
Actually this doesn't work as now the token doesn't test equal for the different instances of MockPlatformInterface, fixing... |
packages/url_launcher/url_launcher_platform_interface/CHANGELOG.md
Outdated
Show resolved
Hide resolved
@@ -3,7 +3,7 @@ description: A common platform interface for the url_launcher plugin. | |||
homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher_platform_interface | |||
# NOTE: We strongly prefer non-breaking changes, even at the expense of a | |||
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes | |||
version: 1.0.4 | |||
version: 1.0.5 |
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.
You'll also want to update the dependency on plugin_platform_interface in this file.
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.
Good point, I'll have to either split this PR into 2, or follow-up with another PR just to bump after publishing the plugin_platform_interface. I'm going with the later as it's the faster path right now.
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.
Actually ended up splitting the PRs
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 once comments are addressed
packages/plugin_platform_interface/lib/plugin_platform_interface.dart
Outdated
Show resolved
Hide resolved
…acheing-01-08 * flutterPlugin/master: (30 commits) Update Gradle version (flutter#2448) [image_picker] support android V2 embedding (flutter#2430) [webview_flutter] Setup XCTests (flutter#2445) [video_player] Fixes video initialization future stall. (flutter#2134) [ci] Upgrade to Xcode 11.3 (flutter#2435) [In_app_purchases] migrate to Play Billing Library 2.0. (flutter#2287) Migrate away from deprecated `BinaryMessages` (flutter#2444) [google_sign_in]Update google_sign_in_example name in pubspec.yaml (flutter#2335) [ios_platform_images] Removed android support from the pubspec. (flutter#2432) [google_sign_in] Expose network error (flutter#2398) [battery] cleanup for Android embedding post 1.12 (flutter#2400) [flutter_webview] Raise min Flutter SDK to stable (flutter#2425) re-enable stable CI (flutter#2402) [in_app_purchase]Change a comment. (flutter#2329) [google_sign_in] Pass the client id to the platform interface. (flutter#2427) [ios_platform_images] Made ios_platform_images set the correct image scale. (flutter#2414) [url_launcher_platform_interface] use non static token for platform interface (flutter#2418) [plugin_platform_interface] Don't use const Object as a token (flutter#2417) Update endorsed macos plugins readme and update others (flutter#2407) [webview_flutter] add gesture navigation for iOS (flutter#2339) ... # Conflicts: # packages/video_player/video_player/CHANGELOG.md # packages/video_player/video_player/pubspec.yaml
Updates the documentation for `PlatformInterface` to reflect that the token should be `static final` rather than `static const`. This was fixed in flutter#2417.
Description
Platform interface tokens must be unique, we've mistakenly used const Objects as a token (and all const Objects are identical).
Thanks @buntagonalprism for noticing and investigating!
We should probably follow-up with the PlatformInterface forcing tokens that are not const Objects (though this will be a breaking change).
I'm not sure whether we can test the failing scenario as it will require running tests in release mode.
Related Issues
flutter/flutter#46941
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze
) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?