Flutter nested lists - custom CheckBox - flutter

I'm really confused about this situation, I'm trying to build this app just like in the image below, the app is all about having a list of ExpansionTiles inside each one there is a list of items, each item has it's own three checkboxes[true, false, avoid], and also the ExpansionTile it self has it's own three checkboxes that can be clicked globally, instead of selecting them one by one,what I need is to get to the best solution to implement this, to know which item in which list were selected and to give a result depending on it, I'm really confused and tried many ways, many models for data, but failed, any help will be really app, I'd be more than glad with any help.enter image description here

I'd create a controlled widget for the three checkboxes, passing parameters for onChange and value (Value can be determined using an enum)
Then I'd reuse that widget everywhere I need
Then I'd go for an expansible widget that contains the list (Column widget maybe?)
Try to handle as many states as possible, having controlled widgets
Or if you're using BloC you can easily implement your core logic with this UI:)

Related

How to create change item from list A to list B using animation

I have a list of words, and arrange them into 1 complete sentence similar to below image. I'm thinking of the idea of ​​creating 2 Widget lists and animating between widget list changes, but don't know how to do it yet. I would like to see if flutter has a lib to do that, or if not, what do I have to research to make such a feature,
realistic image that i want to do

Preserving the State of a Drawer in Flutter

I have a stateful Scaffold widget, where the body contains a list of entities with various properties (e.g. shoes or cars) and Drawer widget, which is empty at first, except for two buttons at the bottom ("Cancel" and "Filter") and a FAB. The user can add various filters with the FAB (e.g. the user can add a shoesize-filter, or a color-filter).
The problem I have is the following: Let's say the user selects various filters and works with them (i.e. ticks checkboxes, enters a shoesize, changes sliders, etc.). When the user is ready to apply the filters, he can click the "Filter" button, which closes the Drawer (onTap -> callback -> Navigator.of(context).pop()). But when the user wants to go back, reopen the Drawer, and adjust one of the filters, it obviously doesn't work, since the widget is being rebuilt from scratch.
Currently, the way the filtering works is, once the "Filter" Button is pressed, all the various values from the added filters are collected into an object FilterPackage, which is then passed via callback to the Scaffold widget, which then applies the values from the FilterPackage to the list of entities.
One solution I came up with, would be feeding this FilterPackage object to the Drawer widget in its constructor, which would provide all the information necessary to rebuild the widget just how it has to be.
Is that a reasonable solution? I have already made some research, but struggled finding a solution on what would clearly be the best and recommended way to preserve the drawer's state. Using PageStorage / PageStorageBucket seems overly complicated for this case. Or am I wrong?
Thanks in advance for any guidance.

How to prevent Stateful Widget stored in List to be disposed?

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.

flutter Child1 send data1 to Parent which forwards data1 to Child2

I have a Form widget with multiple TextFormFields.
As flutter is not that readable I am putting even simple form fields each in its own widget.
No idea wether this is bad...
So I wrapped a TextFormField and a Radio Button group each in its own statefull widget.
Now both can NOT communicate anymore together.
When I change a value on the Radio button widget the Text Form field widget should change its value too.
How can I do that?
Actually I have a parent with 2 children and they need to share data.
I havent found a communiction strategy in flutter for that advanced use case... working with 2 functions here seem really a bad and cumbersome idea...
In angular I used a shared singleton service for such scenarios. Exists there something similar in flutter?
Yes you can use singletons with get_it package https://pub.dev/packages/get_it or use provider to send data between pages

Is it possible to put a List of assets inside a single Image Widget?

I'm new to flutter and I'm very adventurous when it comes to discovering its hidden potential. I've tried a number of ways to implement what I want and I can't find the most effective way.
First, for example, I have a List<String> imagePath = ["assets/img1.jpg","assets/img2.jpg","assets/img3.jpg","assets/img4.jpg"];
I know that the Carousel Widget uses "image" parameter which accepts a list of "Image Widgets".
I know the easiest way to show this List<String> imagePath is to just simply use Listview.builder. But I want to utilize the feature of the Carousel wherein you can modify the transition animation and the most important part is the dot indicator.
SO if you guys have any ideas on how can I put my List inside the Carousel widget, That would be a great help!
I would appreciate any solutions!
If your Carousel receives a list of image widgets you can use the Image.asset constructor with the paths in your list.
https://api.flutter.dev/flutter/widgets/Image/Image.asset.html