Solution 1 :
Take a look at shared preference
When you are adding the text to a list from the on saved method add the text to a List. Save this list in shared preferences. When you create the task card take it from shared preferences
Problem :
i want to make a to do list with input textField but when i refresh the page the list of tasks refreshs too so it become as default
to explain it i want to send a task by the text field and the task enter the list and after we will add a task to the bottom of the listView
class Tasks extends StatefulWidget {
List<tasks> L = [];
bool b = false;
Tasks(this.L, this.b);
@override
State<Tasks> createState() => _TasksState();
}
class _TasksState extends State<Tasks> {
final ctrl = TextEditingController();
@override
void dispose() {
// TODO: implement dispose
super.dispose();
ctrl.dispose();
}
@override
Widget build(BuildContext context) {
return Column(children: [
Visibility(maintainInteractivity: true,maintainState: true,maintainSize: true,maintainAnimation: true,
visible: this.widget.b,
child: TextField(
controller: ctrl,focusNode: FocusNode(descendantsAreFocusable: true),
onSubmitted: (text) => {
setState(() {
String s = text;
this.widget.L.add(tasks(text, []));
ctrl.clear();
})
},
decoration:
InputDecoration(fillColor: Colors.white, hintText: "dafaf"),
style: TextStyle(color: Colors.white, fontWeight: FontWeight.w400),
)),
Expanded(
child: ListView.builder(
itemCount: this.widget.L.length,
itemBuilder: (BuildContext context, int index) {
return Card(
color: Colors.black,
child: Column(
children: [
ListTile(
textColor: Colors.white,
iconColor: Colors.white,
title: Row(children: [
Checkbox(
value: false,
checkColor: Color.fromRGBO(85, 85, 85, 1),
tristate: false,
onChanged: (value) {}),
Text(this.widget.L[index].tite)
])),
],
),
);
},
))
]);
}
}