Flutter DataTable - Tap on row

前端 未结 4 1522
小鲜肉
小鲜肉 2020-12-16 06:25

I am using Flutter DataTables to display list of items in cart. Now I want to edit the quantity of any selected row. Is there a way to get the information of the row user ha

4条回答
  •  渐次进展
    2020-12-16 07:09

    Try this :

    DataTable(
        showCheckboxColumn: false, // <-- this is important
        columns: [
            DataColumn(label: Text('FirstName')),
             DataColumn(label: Text('LastName')),
        ],
         rows:[
            DataRow(
                cells: [
                    DataCell(Text(obj['user1'])),
                    DataCell(Text(obj['name-a'])),
                ],
                onSelectChanged: (newValue) {
                    print('row 1 pressed');
                },
            ),
            DataRow(
                cells: [
                    DataCell(Text(obj['user2'])),
                    DataCell(Text(obj['name-b'])),
                ],
                onSelectChanged: (newValue) {
                    print('row 2 pressed');
                },
            ),
        ]
    ),
    

    Hope this helps. Thanks

提交回复
热议问题