Replies: 3 comments 4 replies
-
Hi @MaxLaps, First off, many thanks for sponsoring the project! 🙏🏻 Much appreciated 😃 To the questions...It is not impossible, nor a bad idea. I have been thinking about it myself as well, even though I have originally stated (see https://docs.flexcolorscheme.com/future_features#out-of-scope) that the package is not intended to support serialization of its configuration and persisting it. But having seen the success and popularity of that in the companion app Themes Playground I'm beginning to change my mind. The solution used in the Themes Playground can however not be transferred to the package directly. That solution is kind of a hack by serialization of the UI control states in the Playground app only. The FlexColorScheme package itself has no knowledge about the serialized format and currently does not support serialization of its data. The URL sharing of the Playground config is then just encoding and compressing the entire Playground json as a super big query param. The config can then also be shared with anybody as a URL link without any server storage of the config. Current version of the Playground is totally serverless (other than hosting the static single page app), it also does not log anything about users and usage. However, this does not mean it could not be done. The Playground's own solution could even co-exist with it for backwards compatibility for a while. Let's dig a bit into the idea and discuss what it would mean and expectations. To support this feature we need to:
Thoughts? Maybe in version 9?I will put this on things to look into and experiment with in a separate branch. Not for the next release, or any 8.x release. Sounds more like something for version 9. Planned next is adding a long list of new theming features to release 8, this in versions of 8.3 and 8.4. Have not really had much free time yet to work on release 8.3, only compiled a list of some things that may come to it https://github.com/rydmike/flex_color_scheme/blob/version-8-3-0/CHANGELOG.md I'm also hoping to move the Playground build to a WASM build and new hosting that supports WASM (GitHub Pages where it is now, does not). I do have a working WASM build already of the Playground on new hosting. But while getting it working with WASM, a performance issue with strings in Dart WASM compiler was discovered, that made the code view page almost unusable. This has been fixed in Dart latest/master and will hopefully land also in next Flutter release (It is claimed to have been fixed and be fast now, I have not tried it, still need to do that too). For version 10, my vision is actually a more or less complete rewrite of the Playground app. It's UI is getting a bit too complex for its own good. It was never intended to do all the things it does now, it was just a humble theming tutorial, as a last step and demo of what FlexColorScheme can do, but it kind of exploded. More Playground history https://docs.flexcolorscheme.com/playground_history#background. Interestingly the import/export has already sort of happened 😃 I need to find time to update the docs site and restructure it too 😅 Export/import visibilityAbout the visibility of the export/import feature, good point! Two options:
Thoughts? I can do either one already in the next release. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the thorough answer! Reading your response, I think you are trying to make a bigger solution than what I'm requesting here or misunderstood my goal/use case. To clarify:
To fulfill my suggestion, the
I've been doing Flutter for less than a month. I tried looking around a bit but I don't want to spend days dissecting it, so I surely don't understand all the subtleties and may be missing spots. But a quick implementation may look like:
Once you have that, all that is left is the dev experience of when does that run that I mention above. Some thoughts about them:
Export/import visibilityYour first idea of moving it to top as a collapsed section is exactly what I had in mind. I feel there are already maybe too many panels on the side, so adding another one seems overkill. You could also rename the panel to something like "Import/Export"? Little FYIIn case you are not aware, the "Paste settings" button does not appear to work on Firefox. Maybe the clipboard handling is different / restricted. Is there a reason textbox isn't an editable field which would allow manual pasting. |
Beta Was this translation helpful? Give feedback.
-
Yes, I understand that, but sadly the To produce the result and feature you, and many other have has asked for as well, the FlexColorScheme data class and all sub-classes it uses, must be fully serializable to/from JSON. Then FlexColorScheme package can then generate the JSON from its current config. Which I can then use in the Playground app as well to make a JSON of whatever config the Playground's We would instead be exporting the actual state of the The hacked UI control serialization in the Playground would basically become obsolete, I would only keep it around to allow migrating old configs for a while. Also the Playground's tedious UI control persistence solution could then also be made a lot simpler. The simplest way to use this export is of course to just save that file in the compiled code. const String themeJSON =
"""
{the big JSON string exported from Playground}
"""; But you could also save it as a file in your project's assets folder, read it as string from there dynamically when app starts and assign it to a string. Likewise you could server from a web server if you like 😄 In both cases you can of course make many different configs and swap between them in your app as desired. To use it and make MaterialApp(
theme: FlexThemeData.fromJSON(themeJSON),
); So you would not need to use any of the generated code, this would be an alternative way to use a config made with the Playground. I would still keep the code gen available too though. Perf wise, yes decoding JSON is not without cost, but we can easily create finals of the decoded result, so that it is only ever decoded once during your app life cycle: final ThemeData myLightTheme = FlexThemeData.fromJSON(themeJSON); Then use that instead as your The However, if you want to make "modifications" on final ThemeData myLightTheme =
FlexColorScheme.fromJSON(themeJSON).copyWith(appBarStyle: FlexAppBarStyle.primary).toTheme; Basically use it as a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Have you thought about moving the playground's JSON import/export system into the core package? I think it would be a nice addition.
The idea would be that instead of copying "Theme code", apps could instead load that JSON configuration and create the Theme code either at runtime or create a genenrated file with a command (or during build? I don't know if that's possible).
Benefits:
I'm aware that the playground can't do everything that this package is capable of. If a dev needs those (more advanced?) feature, it could be done as manual changes after loading the configuration (or as a second argument to the generating function). This way, for those devs, the manuals tweaks are easy to see/find, and updating the config doesn't default to overwriting their tweaks.
If that was to be done, I would then suggest too make the import/export more easily accessible and visible. Maybe put it as part of the "Theme code" section (I mean it's already there, but at the end, easy to miss).
PS: This project is very impressive and your maintenance work here even more so. Few open issues/PR and your replies to them and your answers to them and to discussions are very thorough.
Beta Was this translation helpful? Give feedback.
All reactions