Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Adding a checkbox to the card structure

I have a to-do app that looks like this but I want to put a checkbox to the left of the texts. I’m trying to use the checkbox structure for this, but I can’t add it because child is already full, how can I add a checkbox to the left in the card design. Using row or column doesn’t work it really causes too many errors.

enter image description here

         Expanded(
          child: ListView.builder(
            itemCount: allTodo.length,
            itemBuilder: (context, index) {
              return Card(
                child: ListTile(
                  onTap: () {
                    showDialog(
                      context: context,
                      builder: (BuildContext context) {
                        return AlertDialog(
                          title: Text("New ToDo"),
                          content: Container(
                            child: Column(
                              mainAxisSize: MainAxisSize.min,
                              children: [
                                Form(
                                  key: _formKey,
                                  child: Column(
                                    children: [
                                      buildForm(_controllerTitle, "")
                                    ],
                                  ),
                                ),
                              ],
                            ),
                          ),
                          actions: [
                            TextButton(
                              onPressed: () {
                                Navigator.pop(context);
                              },
                              child: const Text(
                                "Cancel",
                              ),
                            ),
                            buildButton(Colors.indigo, updateObject),
                          ],
                        );
                      },
                    );
                    _controllerTitle.text = allTodo[index].title;
                    clickedTodoID = allTodo[index].id!;
                    setState(() {});
                  },
                  title: Text(allTodo[index].title),
                  trailing: GestureDetector(
                    onTap: () {
                      if (allTodo[index].id != null) {
                        _deleteTodo(allTodo[index].id!, index);
                        setState(() {});
                      } else {
                        print("id is null, cant perform Delete operation");
                      }
                    },
                    child: Icon(Icons.delete),
                  ),
                ),
              );
            },
          ),
        ),

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use leading, add checkbox widget here.

 Expanded(
  child: ListTile(
    //This one 
    leading: Checkbox(),
    title: Text('List Tile'),
  ),
),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading