This is simple for macOS since it can use NSUserDefaults as on iOS. Investigation is needed to figure out what the best equivalents would be for Linux and Windows.
So you forked the shared_preferences package from flutter/plugins repository into a subfolder and they will be merged later, right ?
There's no forking involved, the "plugins" in the flutter_plugins directory here contain only the desktop platform implementations. The are meant to be combined with the actual plugins.
This is a must have desktop feature
For Windows though, since the current plugin API is expected to completely change (right now it shares the Linux C++ API; I expect it to switch to C# later), that's probably premature; discussions about how to proceed with that are still in progress. In the short term, I think adding a Windows implementation of shared_preferences here, with the expectation that it would move to flutter/plugins later, would be reasonable.
@stuartmorgan ATM if we want the plugin to work on windows we need to add linux support with GTK since windows and linux plugins are sharing Linux C++ lib, right ? Or I totally miss understood ?
Sorry, I'm not following the question. Windows and Linux implementations are entirely unrelated, so no, a Linux implementation is not required for a Windows implementation to exist. Even on Linux I don't see where GTK would come into it since shared_preferences has no UI.
I recommend looking at the Windows example plugin to see the basics of implementing a Windows plugin with the C++ API.
I probably miss understood the purpose of GTK, I thought GTK was used as a platform SDK as we do with Android SDK and iOS SDK.
Glad to hear that you created #408 for windows example, I will take a look ! Thanks 👌
Do Windows and Linux have equivalents to NSUserDefaults? I presume we will have to write a json or xml file to disk (sorta like android shared preferences works under the hood). For Linux this can be in $XDG_CONFIG_HOME/bundle_id/shared_prefrences.json (https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html). For Windows we can probably use %AppData%bundle_id/shared_prefrences.json.
I haven't really done C++ stuff extensively so it is probably best that someone who knows more about this implements this.
@csells has been looking into a Windows implementation. I believe what you're describing is basically the approach he is taking.
Correct.
Any updates on this? Debugging all features of mobile applications on Windows will be possible only if there was a working shared_preferences plugin.
Related link of someone developing their own version of shared_preferences
Because there's almost nothing platform-specific about a JSON-based implementation, this ended up driving a lot of deeper discussions and work in Flutter to allow implementing plugins without having to use the same platform channel interface for every platform, which is why this was on hold. That foundation is largely in place now, so this is back on the short-term roadmap.
maybe can try hive
I have implemented for windows, for Linux same code can work but never tried to to time limit, Here is the repo link
https://github.com/ashutosh1211/shared_preferences_desktop
Closing in favor of https://github.com/flutter/flutter/issues/41719 and https://github.com/flutter/flutter/issues/41720; they will be implemented purely in Dart, so aren't subject to the Windows and Linux API and tooling instability, and can thus go directly into flutter/plugins rather than being temporarily hosted here.
You can check this out, too:
https://github.com/flutter/flutter/issues/41719#issuecomment-616669212
On Mon, Apr 20, 2020 at 8:15 AM Ashutosh notifications@github.com wrote:
I have implemented for windows, for Linux same code can work but never
tried, Here is the repo link
https://github.com/ashutosh1211/shared_preferences_desktop—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/google/flutter-desktop-embedding/issues/434#issuecomment-616619104,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AATTAPM3SC4IKWBCEIMFTWDRNRRHNANCNFSM4HYZRAGA
.
Most helpful comment
Correct.