skip to Main Content

How to refresh the data table after data appended

List results = [];
  DataRow _getDataRow(index, data) {
    return DataRow(
      cells: <DataCell>[
        DataCell(Text(results[index]['item_code'])),//add name of your columns here
        DataCell(Text(results[index]['item_name'])),
        DataCell(Text(results[index]['rate'])),
        DataCell(Text("10")),//add name of your columns here
        DataCell(Text("here")),
      ],
    );
  }

2

Answers


  1. actually the function named _getDataRow is a template for the actual objects which will be invoked in the page, so you need to call it and use any state management to update the content, I suggest to use bloc or provider

    Login or Signup to reply.
  2. While a state management using for example BLoC should be preferred,
    for quick testing you can use the setState argument inside of a StatefulWidget like this…

        setState(() {
           results = _getDataRow(someIndex, newData);
        });
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search