table_sticky_headers 2.0.3 copy "table_sticky_headers: ^2.0.3" to clipboard
table_sticky_headers: ^2.0.3 copied to clipboard

outdated

Two-dimension table with both sticky headers. You may scroll left \ right and top \ bottom. Sticky headers always stay visible. Legend cell (top left) always visible too.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'offset_to_cell_page.dart';
import 'simple_table_page.dart';
import 'tap_handler_page.dart';
import 'decorated_table_page.dart';

void main() {
  runApp(
    MaterialApp(
      home: LandingPage(),
    ),
  );
}

class LandingPage extends StatefulWidget {
  final columns = 10;
  final rows = 20;

  List<List<String>> makeData() {
    final List<List<String>> output = [];
    for (int i = 0; i < columns; i++) {
      final List<String> row = [];
      for (int j = 0; j < rows; j++) {
        row.add('L$j : T$i');
      }
      output.add(row);
    }
    return output;
  }

  /// Simple generator for column title
  List<String> makeTitleColumn() => List.generate(columns, (i) => 'Top $i');

  /// Simple generator for row title
  List<String> makeTitleRow() => List.generate(rows, (i) => 'Left $i');

  @override
  _LandingPageState createState() => _LandingPageState();
}

class _LandingPageState extends State<LandingPage> {
  int _selectedIndex = 0;

  Widget _widgetOptions(int index) {
    switch (index) {
      case 0:
        return SimpleTablePage(
          titleColumn: widget.makeTitleColumn(),
          titleRow: widget.makeTitleRow(),
          data: widget.makeData(),
        );
      case 1:
        return TapHandlerPage(
          titleColumn: widget.makeTitleColumn(),
          titleRow: widget.makeTitleRow(),
          data: widget.makeData(),
        );
      case 2:
        return DecoratedTablePage(
          titleColumn: widget.makeTitleColumn(),
          titleRow: widget.makeTitleRow(),
          data: widget.makeData(),
        );
      case 3:
        return OffsetToCellPage(
          titleColumn: widget.makeTitleColumn(),
          titleRow: widget.makeTitleRow(),
          data: widget.makeData(),
        );
      default:
        print('$index not supported');
        return Container();
    }
  }

  void _onItemTapped(int index) {
    setState(() {
      _selectedIndex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: _widgetOptions(_selectedIndex),
      ),
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType
            .fixed, // TODO Without it inactive elements disappear whet its are more then three
        items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            icon: Container(),
            label: 'Simple',
          ),
          BottomNavigationBarItem(
            icon: Container(),
            label: 'Tap Handler',
          ),
          BottomNavigationBarItem(
            icon: Container(),
            label: 'Decorated',
          ),
          BottomNavigationBarItem(
            icon: Container(),
            label: 'Offset',
          ),
        ],
        currentIndex: _selectedIndex,
        selectedItemColor: Colors.amber[800],
        onTap: _onItemTapped,
      ),
    );
  }
}
183
likes
0
pub points
94%
popularity

Publisher

unverified uploader

Two-dimension table with both sticky headers. You may scroll left \ right and top \ bottom. Sticky headers always stay visible. Legend cell (top left) always visible too.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on table_sticky_headers