Flutter PlutoGrid not redrawing after RiverPod StreamProvider triggers rebuild
10:03 27 Nov 2022

I have a Flutter app that includes the PlutoGrid component in a page display. The grid is designed to show a list of objects that are retrieved from a RiverPod StreamProvider, where that provider is drawing data from a FireStore collection.

In the app when I add a new entry I would expect the grid to redraw itself as part of the 'build' process - but it is not!

  @override
  Widget build(BuildContext context) {
    final aGoalStream = ref.watch(goalsListStreamProvider);
    print('rebuild');
    return aGoalStream.when(
      error: (error, stack) => Center(
        child: Text('Error [${error.toString()}]'),
      ),
      loading: () => Center(
        child: CircularProgressIndicator(),
      ),
      data: (data) {
        return Container(
            child: PlutoGrid(
          columns: _columns,
          rows: data.map((e) {
            print('cell');
            return PlutoRow(cells: _toCells(e));
          }).toList(),
        ));
      },
    );
  }

Through the logging 'print' calls I can see that after a new record is posted, the 'aGoalStream = ' code line is being called, and the cells are being refreshed, but the grid does not refresh to display the expected new row.

Any suggestions?

flutter