dimanche 3 novembre 2019

Is there a way to make a checkbox list in flutter where the user can edit the label of that checkbox? For example a task that needs to be completed

I am trying to make a UI for an app that lets the user list tasks and check them off as they get them done. But I want the user to be able to seamlessly edit the names of those tasks and then hit a checkbox for completion.

I have tried using a ListView.Builder from this tutorial

https://miro.medium.com/max/186/1*gE4Qj0fFgLFGlSUiy-rn2w.gif (you might have to copy and paste the Link)

It's just I want to be able to have a checklist show up

Reference:https://medium.com/@DakshHub/flutter-displaying-dynamic-contents-using-listview-builder-f2cedb1a19fb

class DyanmicList extends State<ListDisplay> {
List<String> litems = [];
final TextEditingController eCtrl = new TextEditingController();
@override
Widget build (BuildContext ctxt) {
return new Scaffold(
  appBar: new AppBar(title: new Text("Dynamic Demo"),),
  body: new Column(
    children: <Widget>[
      new TextField(
        controller: eCtrl,
        onSubmitted: (text) {
          litems.add(text);
          eCtrl.clear();
          setState(() {});
        },
      ),
      new Expanded(
        child: new ListView.builder
          (
            itemCount: litems.length,
            itemBuilder: (BuildContext ctxt, int Index) {
              return new Text(litems[Index]);
            }
        )
    )
    ],
  )
  );
  }
  }



Aucun commentaire:

Enregistrer un commentaire