All Projects → MayLau-CbL → flutter_horizontal_data_table

MayLau-CbL / flutter_horizontal_data_table

Licence: MIT license
Flutter Fixed Column Horizontal Datatable Widget

Programming Languages

dart
5743 projects
C++
36643 projects - #6 most used programming language
CMake
9771 projects
c
50402 projects - #5 most used programming language
HTML
75241 projects
swift
15916 projects

Projects that are alternatives of or similar to flutter horizontal data table

flutter-tips
My collection of Flutter development tips
Stars: ✭ 36 (-81.05%)
Mutual labels:  flutter-widget
custom radio grouped button
Custom Flutter widgets that makes Checkbox and Radio Buttons much cleaner and easier.
Stars: ✭ 144 (-24.21%)
Mutual labels:  flutter-widget
FlutterLoadingGIFs
Loading indicator GIFs. Material and Cupertino (Android and iOS) loading indicators in assorted sizes. Use as placeholders for loading remote image assets. Demo: https://gallery.codelessly.com/flutterwebsites/loadinggifs/
Stars: ✭ 28 (-85.26%)
Mutual labels:  flutter-widget
getwidget-docs
Get Widgets UI library docs.
Stars: ✭ 17 (-91.05%)
Mutual labels:  flutter-widget
flutter ui stepper
A flutter challenge to create a stepper
Stars: ✭ 19 (-90%)
Mutual labels:  flutter-widget
instagram-text-editor
An Instagram like text editor Flutter widget that helps you to change your text style.
Stars: ✭ 66 (-65.26%)
Mutual labels:  flutter-widget
Knockdown-Flutter
Enough exercises to knockdown the fear of Flutter in you 👊
Stars: ✭ 33 (-82.63%)
Mutual labels:  flutter-widget
rainbow container
🌈 A magical container which changes colors whenever its build method is called.
Stars: ✭ 21 (-88.95%)
Mutual labels:  flutter-widget
flutter-spinning-wheel
A very customizable spinning wheel widget for Flutter.
Stars: ✭ 110 (-42.11%)
Mutual labels:  flutter-widget
liquid button
Liquify your buttons, web demo at website
Stars: ✭ 18 (-90.53%)
Mutual labels:  flutter-widget
flutter date picker timeline
Gregorian and Jalali customizable date picker as a horizontal timeline
Stars: ✭ 29 (-84.74%)
Mutual labels:  flutter-widget
seo renderer
A Flutter Web Plugin to display Text Widget as Html for SEO purpose
Stars: ✭ 103 (-45.79%)
Mutual labels:  flutter-widget
Motion-Tab-Bar
A beautiful animated flutter widget package library. The tab bar will attempt to use your current theme out of the box, however you may want to theme it.
Stars: ✭ 237 (+24.74%)
Mutual labels:  flutter-widget
car rental lite
A platform for car sharing where users can book any car that suits their needs and wants for their intended journey, from the closest hosts in the community.
Stars: ✭ 28 (-85.26%)
Mutual labels:  flutter-widget
flutter coffee
📱仿luckin coffee的flutter app
Stars: ✭ 38 (-80%)
Mutual labels:  flutter-widget
text-style-editor
Text style editor widget for flutter
Stars: ✭ 25 (-86.84%)
Mutual labels:  flutter-widget
flutter scatter
A widget that displays a collection of dispersed and non-overlapping children
Stars: ✭ 85 (-55.26%)
Mutual labels:  flutter-widget
incrementally loading listview
An extension of the Flutter ListView widget for incrementally loading items upon scrolling
Stars: ✭ 172 (-9.47%)
Mutual labels:  flutter-widget
flutter todos
A cross platform todo list app using flutter, sqlite etc. If you read the code, you will understand how to create simple elegant mobile app using Flutter and Dart language.
Stars: ✭ 60 (-68.42%)
Mutual labels:  flutter-widget
dough
This package provides some widgets you can use to create a smooshy UI.
Stars: ✭ 518 (+172.63%)
Mutual labels:  flutter-widget

horizontal_data_table

pub package issues GitHub Page

ko-fi

A Flutter Widget that create a horizontal table with fixed first column.

Installation

The following is the guide for installation with different dart sdk and flutter version.

minium dart sdk flutter version (stable) package version
<2.12.0 <2.0.1 v2.5.1
<2.12.0 =2.0.1 v2.5.2
>=2.12.0 (enabled null-safety) >=2.0.1 && <3.0.0 3.6.2+1
>=2.12.0 >=3.0.0 latest

Run this command to install latest:

flutter pub add horizontal_data_table

Breaking Change Upgrading to 4.xx

  1. horizontalScrollController and verticalScrollController is removed. Please use onScrollControllerReady to get the returned ScrollController.
  onScrollControllerReady: (vertical, horizontal) {
    _verticalScrollController = vertical;
    _horizontalScrollController = horizontal;
  },

Usage

This shows Widget's full customizations:

HorizontalDataTable(
      {
      required double leftHandSideColumnWidth,
      required double rightHandSideColumnWidth,
      this.tableHeight,
      this.isFixedHeader = false,
      this.headerWidgets,
      this.isFixedFooter = false,
      this.footerWidgets,
      IndexedWidgetBuilder? leftSideItemBuilder,
      IndexedWidgetBuilder? rightSideItemBuilder,
      this.itemCount = 0,
      List<Widget>? leftSideChildren,
      List<Widget>? rightSideChildren,
      this.rowSeparatorWidget = const Divider(
        color: Colors.transparent,
        height: 0.0,
        thickness: 0.0,
      ),
      this.elevation = 3.0,
      this.elevationColor = Colors.black54,
      Color leftHandSideColBackgroundColor = Colors.white,
      Color rightHandSideColBackgroundColor = Colors.white,
      this.onScrollControllerReady,
      this.verticalScrollbarStyle,
      this.horizontalScrollbarStyle,
      this.enablePullToRefresh = false,
      this.refreshIndicatorHeight = 60.0,
      this.htdRefreshController,
      this.onRefresh,
      this.refreshIndicator,
      this.fixedSidePlaceHolderRefreshIndicator,
      this.enablePullToLoadNewData = false,
      this.onLoad,
      this.loadIndicator,
      this.fixedSidePlaceHolderLoadIndicator,
      this.scrollPhysics,
      this.horizontalScrollPhysics,
      }
     )

/// right-to-left mode constructor
HorizontalDataTable.rtl({...same as the above})

  1. Fixed side column(ltr: leftHandSideColumnWidth, rtl: rightHandSideColumnWidth) and horizontal scollable side maximum scrollable area width(ltr: rightHandSideColumnWidth, rtl: leftHandSideColumnWidth) are required to input.
  2. tableHeight is for manually set the table widget's height. The table widget height is using the smaller value of tableHeight and available height. Default is set to null, which is equal to using available height.
  3. isFixedHeader is to define whether use fixed top row header. If true, headerWidgets is required. Default is false.
  4. isFixedFooter is to define whether use fixed bottom row footer. If true, footerWidgets is required. Default is false.
  5. This widget allow set children in two ways, a. Directly add list of child widget (leftSideChildren and rightSideChildren) b. (Recommended) Using index builder to assign each row's widget. itemCount is required to count the number of row.
  6. rowSeparatorWidget is to add Divider of each Row. Default is turned off.
  7. elevation is the shadow between the header row and the left column when scroll start. Default set to 5.0. If want to disable the shadow, please set to 0.0.
  8. elevationColor is for changing shadow color. This should be useful when using dark table background.
  9. added leftHandSideColBackgroundColor and rightHandSideColBackgroundColor for setting the default background of the back of table. Default is set to white following the Material widget.
  10. added horizontalScrollController and verticalScrollController allow maunally jump to certain offset position. added onScrollControllerReady returning vertical and horizontal ScrollController for external use. Please aware that if you have enabled the pull to refresh function, the jump to action may conflict with the pull to refresh action.
  11. verticalScrollbarStyle and horizontalScrollbarStyle are a ScrollbarStyle class object which allows customizing isAlwaysShown, thumbColor, thickness and radius. Default is using system style scrollbar.
  12. enablePullToRefresh is to define whether enable the pull-to-refresh function. Default is setting to false. Detail you may reference to the Pull to Refresh/Load section.
  13. enablePullToLoadNewData is to define whether enable the pull-to-load function. Default is setting to false. Detail you may reference to the Pull to Refresh/Load section.
  14. scrollPhysics and horizontalScrollPhysics are to set scroll physics of the data table. Please aware scrollPhysics may causing conflict when enabling pull-to-refresh feature.

Pull to Refresh/Load

The pull to refresh action is impletemented based on the 'pull-to-refresh' package code. Currently only part of the function is available.

HorizontalDataTable(
      {
        ...
      this.enablePullToRefresh = true,
      this.refreshIndicator: const WaterDropHeader(),
      this.fixedSidePlaceHolderRefreshIndicator,
      this.onRefresh: _onRefresh,
      this.enablePullToLoadNewData = true,
      this.onLoad: _onLoad,
      this.loadIndicator: const ClassicFooter(),
      this.fixedSidePlaceHolderLoadIndicator,
      this.htdRefreshController: _hdtRefreshController,
      }
     )
      
  1. refreshIndicator is the header widget when pull to refresh. Supported refreshIndicator:

    1. ClassicHeader
    2. WaterDropHeader
    3. CustomHeader
    4. BezierHeader
    5. PlaceholderHeader

    Basically single level header with a certain height while refreshing. For the on-top header is currently not supported. Since refreshIndicator is a Widget type field, you may customize yourself on the header, but you must set the height of the header. The detail usage you may reference to the pull-to-refresh package.

  2. fixedSidePlaceHolderRefreshIndicator is the fixed column side part refresh indicator. This aims to synchronize the action on both side. Prefer using PlaceholderHeader.

  3. refreshIndicatorHeight is the height of the refreshIndicator. Default is set to 60.

  4. onRefresh is the callback from the refresh action.

  5. loadIndicator is the header widget when pull to load. Supported refreshIndicator:

    1. ClassicFooter
    2. CustomFooter
    3. PlaceholderFooter
  6. fixedSidePlaceHolderLoadIndicator is the fixed column side part load indicator. This aims to synchronize the action on both side. Prefer using PlaceholderFooter.

  7. onLoad is the callback from the load action.

  8. htdRefreshController is the wrapper controller for returning the refresh or load result. This is the example on how to use onRefresh and htdRefreshController.

    void _onRefresh() async {
      //do some network call and get the response
      
      if(isError){
        //call this when it is an error case
        _hdtRefreshController.refreshFailed();
      }else{
        //call this when it is a success case
        _hdtRefreshController.refreshCompleted();
      }      
    },
    
    void _onLoad() async {
      //do some network call and get the response
      
      if(isError){
        //call this when it is an error case
        _hdtRefreshController.loadFailed();
      }else if(isNoMoreData){
        //call this when it is end loading data
        _hdtRefreshController.loadNoData();
      }else{
        //call this when it is a success case
        _hdtRefreshController.loadCompleted();
      }      
    },
    

All of this 4 params are required when enablePullToRefresh is set to true.

Example

import 'package:flutter/material.dart';
import 'package:horizontal_data_table/horizontal_data_table.dart';

import 'data/user.dart';

class SimpleTablePage extends StatefulWidget {
  SimpleTablePage({
    Key? key,
    required this.user,
  }) : super(key: key);
  final User user;

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

class _SimpleTablePageState extends State<SimpleTablePage> {
  @override
  void initState() {
    widget.user.initData(100);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Simple Table')),
      body: HorizontalDataTable(
        leftHandSideColumnWidth: 100,
        rightHandSideColumnWidth: 600,
        isFixedHeader: true,
        headerWidgets: _getTitleWidget(),
        leftSideItemBuilder: _generateFirstColumnRow,
        rightSideItemBuilder: _generateRightHandSideColumnRow,
        itemCount: widget.user.userInfo.length,
        rowSeparatorWidget: const Divider(
          color: Colors.black54,
          height: 1.0,
          thickness: 0.0,
        ),
        leftHandSideColBackgroundColor: Color(0xFFFFFFFF),
        rightHandSideColBackgroundColor: Color(0xFFFFFFFF),
      ),
    );
  }

  List<Widget> _getTitleWidget() {
    return [
      _getTitleItemWidget('Name', 100),
      _getTitleItemWidget('Status', 100),
      _getTitleItemWidget('Phone', 200),
      _getTitleItemWidget('Register', 100),
      _getTitleItemWidget('Termination', 200),
    ];
  }

  Widget _getTitleItemWidget(String label, double width) {
    return Container(
      child: Text(label, style: TextStyle(fontWeight: FontWeight.bold)),
      width: width,
      height: 56,
      padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
      alignment: Alignment.centerLeft,
    );
  }

  Widget _generateFirstColumnRow(BuildContext context, int index) {
    return Container(
      child: Text(widget.user.userInfo[index].name),
      width: 100,
      height: 52,
      padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
      alignment: Alignment.centerLeft,
    );
  }

  Widget _generateRightHandSideColumnRow(BuildContext context, int index) {
    return Row(
      children: <Widget>[
        Container(
          child: Row(
            children: <Widget>[
              Icon(
                  widget.user.userInfo[index].status
                      ? Icons.notifications_off
                      : Icons.notifications_active,
                  color: widget.user.userInfo[index].status
                      ? Colors.red
                      : Colors.green),
              Text(widget.user.userInfo[index].status ? 'Disabled' : 'Active')
            ],
          ),
          width: 100,
          height: 52,
          padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
          alignment: Alignment.centerLeft,
        ),
        Container(
          child: Text(widget.user.userInfo[index].phone),
          width: 200,
          height: 52,
          padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
          alignment: Alignment.centerLeft,
        ),
        Container(
          child: Text(widget.user.userInfo[index].registerDate),
          width: 100,
          height: 52,
          padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
          alignment: Alignment.centerLeft,
        ),
        Container(
          child: Text(widget.user.userInfo[index].terminationDate),
          width: 200,
          height: 52,
          padding: EdgeInsets.fromLTRB(5, 0, 0, 0),
          alignment: Alignment.centerLeft,
        ),
      ],
    );
  }
}

Issues Report and Feature Request

Thank you for your reporting and suggestion making this package more complete!

Since many developers get in touch with this package in different places (pub.dev, GitHub, and others website recommandation), I have received your voice regarding to feature request, issue report and question via different channels.

To avoid missing of the messages, I have created the issue templates on GitHub which allow our conversations with ease, especially some discussions are complex when they need to talk with the sample code.

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].