Is this possible to make checklist like iPhone Notes? If user press delete/backspace button keyboard on empty textfield is also delete the checklist and if user press return button on keyboard that will add new checklist?
What I have done is still stuck in how to implement that. I have created class for textfield with checkbox and make an object from them to form class.
class SubTaskItem extends StatefulWidget {
TextEditingController? textEditingController =
TextEditingController(text: '');
SubTaskItem({Key? key, this.textEditingController}) : super(key: key);
@override
_SubTaskItemState createState() => _SubTaskItemState();
}
class _SubTaskItemState extends State<SubTaskItem> {
bool checkboxValue = false;
@override
void initState() {
// TODO: implement initState
super.initState();
widget.textEditingController = TextEditingController(text: '');
}
@override
Widget build(BuildContext context) {
return CheckboxListTile(
value: checkboxValue,
onChanged: (val) {
setState(() => checkboxValue = val!);
},
title: TextFormField(
controller: widget.textEditingController,
style: TextStyle(fontSize: 14.0),
),
controlAffinity: ListTileControlAffinity.leading,
activeColor: Colors.green,
);
}
}
on Class Form I add object for subTaskItem with this
List<SubTaskItem> listSubTaskItem = [];
addSubTaskItem() {
SubTaskItem subTaskItem = SubTaskItem();
listSubTaskItem.add(subTaskItem);
setState(() {});
}
Do I need to implement getx for state management or is there any simply way to do that? Thanks
Aucun commentaire:
Enregistrer un commentaire