serverside_datatable 0.0.22

Simplified generic serverside datatable by only providing the fetch implementation.

Serverside Datatable that handle the pagination for you. All you need to do is implement the ServersideRepository class which define your fetch implementation.

Features

  • Pagination
  • Filter is not supported yet.

Getting started

Usage

  1. Create a class that extends ServersideRepository.
  2. Create PODO (Plain Old Dart Object) class.
class FooBar {
    double foo;
    double bar;

    FooBar(this.foo, this.bar);
}

class FooBarRepository extends ServerSideRepository<FooBar> {

    @override
    Future<ServerSideResponse<FooBar>> fetchData(int offset, int limit) async {
        final fooBars = [
            FooBar(5, 5),
            FooBar(1, 3),
            FooBar(2, 4),
            FooBar(8, 9),
        ];
        final totalRecords = fooBars.length;
        if (offset + limit > totalRecords) limit = totalRecords;
        return ServerSideResponse(fooBars.getRange(offset, limit), totalRecords);
    }
}

ServerSideDataTable<FooBar>(
    repository: FooBarRepository(),
    columns: [
        ServerSideColumn(
            header: "Foo",
            field: "foo",
            renderer: (FooBar rowData) => Text(rowData.foo),
        ),
        ServerSideColumn(
            header: "Bar",
            field: "bar",
            renderer: (FooBar rowData) => Text(rowData.bar),
        ),
    ],
)

Additional information