bs_flutter_datatable 1.0.3 copy "bs_flutter_datatable: ^1.0.3" to clipboard
bs_flutter_datatable: ^1.0.3 copied to clipboard

outdated

Simple way to show data using datatable response with serverside processing

example/lib/main.dart

import 'dart:convert';

import 'package:bs_flutter_datatable/bs_flutter_datatable.dart';
import 'package:bs_flutter_datatable_example/source.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  ExampleSource _source = ExampleSource();
  BsDatatableController _controller = BsDatatableController();

  @override
  void initState() {
    super.initState();
  }

  Future loadApi(Map<String, dynamic> params) {
    return http
        .post(
      Uri.parse('http://localhost/api-datatables.php'),
      body: params,
    )
        .then((value) {
      Map<String, dynamic> json = jsonDecode(value.body);
      setState(() {
        _source = ExampleSource(
          response: BsDatatableResponse.createFromJson(json),
        );
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Scrollbar(
          child: SingleChildScrollView(
            child: Container(
              padding: EdgeInsets.all(20.0),
              child: BsDatatable(
                source: _source,
                controller: _controller,
                searchable: true,
                pageLength: true,
                paginations: [
                  'previous',
                  'button',
                  'next',
                ],
                columns: <BsDataColumn>[
                  BsDataColumn(
                      label: Text('No'),
                      orderable: false,
                      searchable: false,
                      width: 100.0),
                  BsDataColumn(label: Text('Code'), width: 200.0),
                  BsDataColumn(label: Text('Name')),
                ],
                serverSide: loadApi,
              ),
            ),
          ),
        ),
      ),
    );
  }
}
19
likes
0
pub points
61%
popularity

Publisher

unverified uploader

Simple way to show data using datatable response with serverside processing

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

bs_flutter_responsive, bs_flutter_utils, flutter, flutter_web_plugins

More

Packages that depend on bs_flutter_datatable