How to update the table if page is changed and values refreshed from API in flutter

I am using PaginatedDataTable in my application. Using API, i am fetching first 10 set of row values and displaying, if i click next page, i increased my page number and again called getAPI(). But it is updating anything.

One more issue, when fetching next time , my index values start from 0 to 9 . but in getRow() method in DataSource starts from 11.

How to overcome these issues.

DataSource:

class TableDataSource extends DataTableSource {
  TableData tableData;
  TableDataSource(this.tableData);
  int _selectedCount = 0;
  DataRow getRow(int index) {
    assert(index >= 0);
    if (index >= tableData.value.totalElements) return null;
    var data = tableData.value.content[index];

    return DataRow.byIndex(index: index, cells: getDataCells(data));
  }

  List<DataCell> getDataCells(dynamic data) {
    List<DataCell> dataCellList = new List<DataCell>();
    for (int i = 0; i < data.values.length; i++) {
      var cell = new DataCell(
        child: Text(
          data.values[i].toString(),              
      ));
      dataCellList.add(cell);
    }
    return dataCellList;
  }

  @override
  bool get isRowCountApproximate => false;

  @override
  int get rowCount => tableData.value.totalElements;

  @override
  int get selectedRowCount => _selectedCount;
}

Inside Build method:

PaginatedDataTable(
              header: getHeader(),
              columns: getColumns(tableData),
              source: TableDataSource(tableData),
              onPageChanged: (value) {
                offset++;
                fetch();
              },
            )

how to fetch 10 datas from API and again in next page click another 10 datas.

Any help is really appreciated

Have you figured out?