setItems method

void setItems(
  1. List<T> items, {
  2. bool replace = false,
  3. bool reload = false,
})

Set items to populate the table.

If replace is true, all the items populating the table will be replaced, otherwise new items will be appended. Note that this is required to manage two different logics:

  • If you want a table with single visbile pages to be scrolled throug navigation controls, you should replace the items every time the user changes page.
  • If you want a table with a scrolling pagination (i.e. the user arrives to the bottom of the table and new data loads), new items should be appendend to the initial ones.

Implementation

void setItems(List<T> items, {bool replace = false, bool reload = false}) {
  if (!replace) {
    this.dataItems.addAll(List.of(items));
  } else {
    this.dataItems = List.of(items);
  }
  dataItemsToShow = _evaluateRowsToShow(replace: replace);

  if (reload) {
    notifyListeners();
  }
}