bosskmk / pluto_grid

PlutoGrid is a dataGrid for flutter that can be controlled by the keyboard on desktop and web. Of course, it works well on Android and IOS.
https://pluto.weblaze.dev
MIT License
639 stars 293 forks source link

[INCIDENT REPORT] Error: Unsupported operation: addAll when PlutoGrid widget has rows as constant empty list #871

Closed adds08 closed 11 months ago

adds08 commented 1 year ago

So I had flutter linter add constant into PlutoGrid widget's rows property. This is because I want to first show loading and my data is populated only after a future is called.

ref.listen(fetchApplicantListsRepoProvider, (prev, next) {
  next.whenOrNull(
    // loading: () => stateManager.setShowLoading(true),  
    data: (data) async {
    // showDialog(context: context, builder: (context) =>  InterviewAppointmentCard());  
    await PlutoGridStateManager.initializeRowsAsync(columns(ref), data).then((value) {
      ref.read(tableToolsProvider.notifier).stateManager.refRows.addAll(List.from(data));
      ref.read(tableToolsProvider.notifier).stateManager.setShowLoading(false, notify: true);
    });
  },
  );
});

Since the addition of const, ref.read(tableToolsProvider.notifier).stateManager.refRows.addAll(List.from(data)); kept showing error that was not shown before. Turns out that I had accidentally added const on rows

PlutoGrid(
  mode: PlutoGridMode.popup,
  onSelected: (event) { },
  configuration: plutoConfiguration(ref),
  onLoaded: (event) {
    ref.read(tableToolsProvider.notifier).setStateManager(event.stateManager);
    ref.read(tableToolsProvider.notifier).stateManager.setShowLoading(true);
    ref.read(tableToolsProvider.notifier).stateManager.setShowColumnFilter(true);
    // stateManager.setAutoEditing(false);
  },
  columns: columns(ref),
  // do not put const, else future values from addres using stateManager refRows will not work since rows are constant
  rows: [],
),
github-actions[bot] commented 11 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 11 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.