Is there any way to serialize the Build layout of a stateless flutter widget and save it to a database?
I would like to design many simple Badge widgets and don‘t want to update the App each Time I have a new one.
I would like to save new widgets to a db instead.
Remote flutter widgets - may be the direction. It has mechanism for rendering widgets based on declarative UI descriptions that can be obtained & rendered at runtime.
Related
I am just learning flutter and I am wondering if it is possible to change the properties of a widget from the code.
I am familiar with WPF, where I can just access the Elements by a name that is given to them (e.g. "btnIncreaseCounter") and then say btnIncreaseCounter.Background = Colors.Orange.
Does a similar concept exist in Flutter? Or how do I modify my widgets from the code?a
You can do it in flutter using key of particular widget,
but flutter is not designed to code this way, flutter provides you with much easy and best practices to achieve the same.
I am using a DropdownButton in a Flutter app, and when you click it and the drop down appears, it overlays a webview that I'm using.
That all works perfectly, however webviews in Flutter, when run as a web app (which this is) trap all UI interactions and don't allow clicks to flow through to the Flutter UI elements.
There is a PointerInterceptor component that handles this perfectly, all I need to be able to do is wrap all of the DropdownMenuItems that appear inside of a single pointer interceptor (because if I individually wrap them then there is a really bad performance hit).
However - the DropdownMenuItems appear in the widget tree directly under the MaterialApp widget - and that is too high in the tree for me to wrap in a PointerInterceptor.
That is the reason that I want to know :
Is it possible to specify where in the widget tree the DropdownMenuItem widgets' appear when a DropdownMenuButton is clicked ?
I am new to Flutter. Everything in Flutter is a widget, and there are two types of widgets, which are Stateless and Stateful. Understood that stateless widgets are widgets that will not change or user can't interact with (texts, icons, etc) while stateful widgets are widgets that will change its state for example because of user interactions.
When we want to create a new custom page we usually extends the page from StatelesWidget or StatefulWidget. Since a StatelesWidget can have StatefulWidget as its children and vice-versa, then when should we extend a page as a StatefulWidget or as a StatelessWidget?
Thank you.
If the page itself has some kind of status, then it should be a stateful widget. For example you want to load something remotely, and display a progress indicator while data is being fetched. When loading is complete, the state of the page is changed, and instead of the progress indicator you display whatever you want.
But it is also possible that the page itself is a stateless widget, and has a child widget, a container for example, and this container is stateful, managing the above mentioned remote loading or depends on some kind of user interaction.
State management is a central issue in Flutter, you have many options, and it is not always easy to find the best. You can easily get into fighting the framework instead of letting it to do the job for you. If you are new to this, I would suggest watching some videos, they helped me a lot, for example this or this.
As far as I know Flutter have build in widget system that named material and cupertino. But is there any other widgets sets. I want to build site with Flutter but do not want to make it look as mobile app.
No there isn't any other widget set. Flutters material and cupertino are ment to get your app a native look. They don't have any special functionality than visual design.
If you just want to do your own styling and elements, you can build your widgets by your own. You can read more about it here:
https://www.raywenderlich.com/10126984-creating-reusable-custom-widgets-in-flutter
Let me start by explaining the problem. I have several buttons which are created based on data I'm getting from a server. On each button click I need to create and display a widget which will present me some data (this widget is also built dynamically). The state of this widget has to be preserved during the lifetime of the app. (for example if I click another button and show a different widget, I need to be able to click on the first button and show the first widget in its preserved state). Number of buttons can also be changed during the app lifetime.
I tried using IndexedStack to achieve this, but when the number of buttons is changed I need to add "pages" to IndexedStack, therefore I need to recreate a new IndexedStack which will have some of my old widgets, so I pull widgets from a List or create new ones if needed. This works great, except Flutter calls dispose() method on my widgets which are stored in the list. I tried using the AutomaticKeepAliveClientMixIn but it didn't help.
I'm guessing this has something to do that the widgets get detached from the parent, but when I reattach them to new parent (new Indexed stack) Flutter doesn't figure out this properly.
Any ideas?
Try to store data to local storage or sqlite for persistence data.