-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[shared_preferences] Adds macOS support with example app #2385
Conversation
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 with some minor nits; I made some changes to your CHANGELOGs to describe what actually changed.
packages/shared_preferences/shared_preferences_macos/CHANGELOG.md
Outdated
Show resolved
Hide resolved
| @@ -1,3 +1,7 @@ | |||
| ## 0.1.0+1 | |||
|
|
|||
| * Adds `package:shared_preferences_macos`. | |||
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.
| * Adds `package:shared_preferences_macos`. | |
| * Increase minimum Flutter SDK to 1.12.8. |
Would it make sense to do this change in a separate PR?
| @@ -1,3 +1,7 @@ | |||
| ## 1.0.1 | |||
|
|
|||
| * Adds `package:shared_preferences_macos`. | |||
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.
| * Adds `package:shared_preferences_macos`. | |
| * Increase minimum Flutter SDK to 1.12.8. |
Would it make sense to do this change in a separate PR?
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.
This was required by the CI tests. Failing if the version wasn't increased.
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.
Sorry, another PR was landed before this one, changing the version and changelog covering your suggestion. I still had to bump the version and the only change was adding the macos package.
| import 'package:e2e/e2e.dart'; | ||
|
|
||
| void main() { | ||
| E2EWidgetsFlutterBinding.ensureInitialized(); |
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.
I think that e2e tests should live in the app-facing plugin, not the platform implementation. Otherwise they'll be duplicated for every platform.
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.
But these are the only test we have for the package. IIUC, If somebody edits the package and breaks it, the app-facing plugin wouldn't detect it, is that right?
If we don't need them here, then we don't need the example app at all since that was it's only purpose.
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.
I think it makes sense to have the app-facing plugin's example app include every endorsed platform implementation, not just iOS and Android.
For plugins that have lightweight e2e integration tests like this one, we can teach our CI to run tests using the app-facing plugin's example app for every endorsed platform implementation, using a path dependency. That doesn't need to happen to land this PR, but I think we should file an issue and start heading in that direction.
We can also have heavyweight integration tests involving a native UI / lifecycle interaction, and in fact I'm planning to land an Espresso test of shared_preferences as soon as #2369 lands. I think these tests should still live in the app-facing plugin though, so that they can share the Dart code of the example app.
@amirh may have opinions about this as well
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.
Yeah, this pr adds macos testing on the app-facing plugin. #2386 This example app was suggested by @amirh to be able to test the macos package and be "self contained". I'm wondering if we need them since once that pr is landed, any changes to the macos plugin will trigger the app-facing tests which will run the macos implementation.
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.
This is fine for now but let's figure out how to share example app code in the future. It seems like we may be able to do it with dependency overrides.
Filed flutter/flutter#46716 (maybe we can reference that in a TODO?)
| runApp(MyApp()); | ||
| } | ||
|
|
||
| class MyApp extends StatelessWidget { |
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.
Do we need to have this app? It seems like it would be preferable to re-use the app-facing plugin's example app.
.../android/app/src/main/java/io/flutter/plugins/sharedpreferencesexample/MainActivityTest.java
Show resolved
Hide resolved
Co-Authored-By: Collin Jackson <[email protected]>
6e3304c to
d05b18b
Compare
…tter#2385)" This reverts commit 7c01e67. # Conflicts: # packages/shared_preferences/shared_preferences_platform_interface/CHANGELOG.md # packages/shared_preferences/shared_preferences_platform_interface/pubspec.yaml
Description
Adds the macos implementation of the shared_preferences plugin.
Tested by adding a example app that runs the e2e tests.
Related Issues
Fixes flutter/flutter#41718
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?