Issue
I'm new to Flutter and I'm making a todo app. I have used alertdialog in the application and I want to add a widget that can be managed with tiles in a list view with a button, just like in the picture, how can I do this?
rel="nofollow noreferrer"> [2
Solution
First, you need to save your data, for this, you can use localstorage.
https://pub.dev/packages/localstorage
You can create storage with this command.
final LocalStorage storage = new LocalStorage('todolist');
Then you can save todos to this storage.
saveToStorage() {
storage.setItem('todos', list.toJSONEncodable());
}
You can use storage clear to delete all todos.
await storage.clear();
With this, you can now save Todos to your app. After this, you need to create a FutureBuilder, with this you can create TodoList. Something like this, you can change it to whatever you want.
FutureBuilder(
future: storage.ready,
builder: (BuildContext context, AsyncSnapshot snapshot) {
List<Widget> widgets = list.items.map((item) {
return CheckboxListTile(
value: item.done,
title: Text(item.title),
selected: item.done,
onChanged: (_) {
_toggleItem(item);
},
);
}).toList();});
Answered By - CidQu
Answer Checked By - Senaida (JavaFixing Volunteer)