I'm trying to refresh a DataGrid after I filter the data source using a text field and a button.
The data is provided by a StreamProvider.
Future<bool> getStreamData(context) async {
_patients = Provider.of<List<PatientModel>>(context);
_patients = _patients.where((patient) => patient.isTester == sett.areTesters).toList();
_patientsDataSource = PatientDataSource(_patients, _fireStoreDataBase);
_patientsDataSource.updateDataGridSource();
return true;
}
This is how it's called.
..
return FutureBuilder(
future: getStreamData(context),
builder: (BuildContext context, value) {
if (value.hasData) {
return SfDataGridTheme(
..
And I get the data in the DataGrid.
But when I filter, I call this function that updates the list of patients, but the datagrid is not refreshed.
filterByEmail(fieldValue) {
_patients = _patients.where((patient) => patient.email!.toLowerCase().contains(fieldValue.toLowerCase())).toList();
_patientsDataSource = PatientDataSource(_patients, _fireStoreDataBase);
_patientsDataSource.buildDataGridRows();
_patientsDataSource.updateDataGridSource();
}