title: Flutter Alert Dialog Data Table Checkbox
body: <p>I am having a data table with checkbox inside alert dialog box, When i click the check box, it is not checking(Checked=checked) the box. I followed this <a href="https://www.youtube.com/watch?v=DupniuA45l4" rel="nofollow noreferrer">video</a></p>
  
  <p>Here is my try out</p>
  
  <pre><code>import 'package:flutter/material.dart';
  
  void main(){
    runApp(new MaterialApp(
      debugShowCheckedModeBanner: false,
      home: new DataTableDemo(),
      theme: ThemeData.light(),
    ));
  }
  
  class DataTableDemo extends StatefulWidget {
  
    final String title = "Data Table Flutter Demo";
  
    @override
    DataTableDemoState createState() =&gt; DataTableDemoState();
  }
  
  class DataTableDemoState extends State&lt;DataTableDemo&gt; {
    List&lt;User&gt; users;
    List&lt;User&gt; selectedUsers;
    bool sort;
  
    @override
    void initState() {
      sort = false;
      selectedUsers = [];
      users = User.getUsers();
      super.initState();
    }
  
    onSortColum(int columnIndex, bool ascending) {
      if (columnIndex == 0) {
        if (ascending) {
          users.sort((a, b) =&gt; a.firstName.compareTo(b.firstName));
        } else {
          users.sort((a, b) =&gt; b.firstName.compareTo(a.firstName));
        }
      }
    }
  
    onSelectedRow(bool selected, User user) async {
      setState(() {
        if (selected) {
          selectedUsers.add(user);
        } else {
          selectedUsers.remove(user);
        }
      });
    }
  
    deleteSelected() async {
      setState(() {
        if (selectedUsers.isNotEmpty) {
          List&lt;User&gt; temp = [];
          temp.addAll(selectedUsers);
          for (User user in temp) {
            users.remove(user);
            selectedUsers.remove(user);
          }
        }
      });
    }
  
    SingleChildScrollView dataBody() {
  
      return SingleChildScrollView(
        scrollDirection: Axis.vertical,
        child: DataTable(
          sortAscending: sort,
          sortColumnIndex: 0,
          columns: [
            DataColumn(
                label: Text("FIRST NAME"),
                numeric: false,
                tooltip: "This is First Name",
                onSort: (columnIndex, ascending) {
                  setState(() {
                    sort = !sort;
                  });
                  onSortColum(columnIndex, ascending);
                }),
            DataColumn(
              label: Text("LAST NAME"),
              numeric: false,
              tooltip: "This is Last Name",
            ),
          ],
          rows: users
              .map(
                (user) =&gt; DataRow(
                        selected: selectedUsers.contains(user),
                        onSelectChanged: (b) {
                          print("Onselect");
                          onSelectedRow(b, user);
                        },
                        cells: [
                          DataCell(
                            Text(user.firstName),
                            onTap: () {
                              print('Selected ${user.firstName}');
                            },
                          ),
                          DataCell(
                            Text(user.lastName),
                          ),
                        ]),
              )
              .toList(),
        ),
      );
    }
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),
        ),
        floatingActionButton: new FloatingActionButton(
          child: new Icon(Icons.add),
          onPressed: (){
            showDialog(
              context: context,
              builder: (_) =&gt; new AlertDialog(
                title: new Text('Data Table Flutter'),
                content: new Container(
                  height: 500,
                  width: 400,
                  child: new SingleChildScrollView(
                    scrollDirection: Axis.horizontal,
                    child: new Column(
                      children: &lt;Widget&gt;[
                        dataBody()
                      ],
                    ),
                  )
                ),
                actions: &lt;Widget&gt;[
                  new OutlineButton(
                    child: Text('SELECTED ${selectedUsers.length}'),
                    onPressed: () {},
                  ),
                  new OutlineButton(
                    child: Text('DELETE SELECTED'),
                    onPressed: selectedUsers.isEmpty
                        ? null
                        : () {
                            deleteSelected();
                          },
                  ),
                ],
              )
            );
          },
        ),
      );
    }
  }
  
  class User {
    String firstName;
    String lastName;
  
    User({this.firstName, this.lastName});
  
    static List&lt;User&gt; getUsers() {
      return &lt;User&gt;[
        User(firstName: "Aaryan", lastName: "Shah"),
        User(firstName: "Ben", lastName: "John"),
        User(firstName: "Carrie", lastName: "Brown"),
        User(firstName: "Deep", lastName: "Sen"),
        User(firstName: "Emily", lastName: "Jane"),
      ];
    }
  }
  </code></pre>
  
  <p>Please let me know, is some thing is missing or some thing I need to change. It will be very helpful for me. Thanks in advance.</p>