-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[shared_preferences] Adds support for Windows #2631
Conversation
packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart
Outdated
Show resolved
Hide resolved
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 just did a quick skim of the Dart code; not a full review.
Capturing from offline discussion:
- We shouldn't check in the Windows example folder, since it isn't stable. (Instead, CI should
flutter create
it on demand, so it's always using the current template iteration.) flutter create .
makes a much of changes to older ios/ and android/ directories; all those changes should be removed from the PR.
packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart
Outdated
Show resolved
Hide resolved
packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart
Outdated
Show resolved
Hide resolved
packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart
Outdated
Show resolved
Hide resolved
packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart
Outdated
Show resolved
Hide resolved
packages/shared_preferences/shared_preferences_windows/lib/src/win32.dart
Show resolved
Hide resolved
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 looking really good. There are a couple of questions we'll need to get input on, but I think it's really close.
packages/shared_preferences/shared_preferences/lib/shared_preferences.dart
Outdated
Show resolved
Hide resolved
packages/shared_preferences/shared_preferences/lib/shared_preferences.dart
Outdated
Show resolved
Hide resolved
static SharedPreferencesStorePlatform get _store => | ||
SharedPreferencesStorePlatform.instance; | ||
static SharedPreferencesStorePlatform get _store { | ||
if (LocalPlatform().isWindows) { |
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 forgot that the registration of the default implementation is in the platform interface rather than this layer; this override has the unfortunate effect that setting a different instance explicitly (e.g., the in-memory implementation, or an unofficial alternate version) won't work on Windows.
I wonder if we should temporarily add a static property to disable this, so that in those cases people can get the dynamic behavior with, e.g., SharedPreferencesStorePlatform.disablePlatformOverride = true;
before calling getInstance()
. Removing it later when we don't need it would technically be a breaking change, but it would be a very easy one for people to deal with (just remove the line of code). @amirh, thoughts?
@@ -0,0 +1,27 @@ | |||
// Copyright 2019 The Chromium Authors. All rights reserved. |
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.
Does flutter/plugins not use an identical license everywhere like flutter/engine?
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 license is the same as the one in shared_preferences
, other than the year. Is that what you are referring to?
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.
Specifically I was wondering if we are using a set year. flutter/engine does that, to avoid having a ton of license variations (which adds size to Flutter applications, since they include all the licenses).
packages/shared_preferences/shared_preferences_windows/android/src/main/AndroidManifest.xml
Outdated
Show resolved
Hide resolved
@@ -0,0 +1 @@ | |||
TODO: Add your license here. |
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.
We should either have a license, or remove the file; it looks like both have been done. I'm not sure if one or the other is the preferred practice going forward so someone who knows should weigh in.
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 just copied the license from the front-end package
packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart
Show resolved
Hide resolved
All comments have been addressed. Now waiting on Also waiting on @amirh comments for the class registration. |
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.
Just some license questions left from me.
@@ -0,0 +1,27 @@ | |||
// Copyright 2019 The Chromium Authors. All rights reserved. |
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.
Specifically I was wondering if we are using a set year. flutter/engine does that, to avoid having a ton of license variations (which adds size to Flutter applications, since they include all the licenses).
...hared_preferences/shared_preferences_windows/example/test_driver/shared_preferences_e2e.dart
Show resolved
Hide resolved
...ages/shared_preferences/shared_preferences_windows/test/shared_preferences_windows_test.dart
Show resolved
Hide resolved
I changed the licenses to 2017 to match the rest of the repo. I have seen licenses with 2020 and 2019 in other packages, so I'm not really sure what's the policy. @amirh or @collinjackson might know? |
https://github.com/flutter/plugin_tools/pull/95 got merged, is anything else standing in the way of this PR being merged? I'm really excited for this to be official (I'm using it as a local path dependency and its great) |
Filed flutter/flutter#56143 to track what's still blocking this PR. |
packages/shared_preferences/shared_preferences_windows/lib/shared_preferences_windows.dart
Outdated
Show resolved
Hide resolved
packages/shared_preferences/shared_preferences_windows/pubspec.yaml
Outdated
Show resolved
Hide resolved
Can someone please provide instructions on how to use/test this PR with your app? I imagine add a specific reference/patch to this MR in |
I hope this pr would be merged soon. 😄 |
I tried to use the PR, by specifying below in
But, got this error:
Haven't found a solution yet, can someone please help? |
I had use this to make it working: Step 1: Step 2: Update
Anyway, the functionality works in this PR. |
Getting weird issue with isLinux and isWindows not defined--see below
I tried this but get an issue when trying to run it in my app:
Flutter Doctor: |
Description
Dart implementation of the
shared_preferences
plugin using ffi for Windows.Related Issues
flutter/flutter#41719
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?