搜尋套件、儲存庫與 APP 分類

editable 封面
套件詳情v2.0.0

editable

一個高度可自訂、可編輯的資料表格(電子試算表)套件,適用於Flutter專案。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
837
喜歡數
223
Pub 分數
150

安裝套件

flutter pub add editable

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

可編輯套件為Flutter應用程式提供了一個高度可客製化的類似電子試算表資料表。它允許使用者互動式編輯單元格,支援動態行列管理,並提供廣泛的樣式與事件處理選項。適用於表單、資料輸入介面以及即時協作工具,在所有主要平台(包含行動、Web與桌面)上皆可運作。此套件設計時著重於效能與彈性,讓開發者能依特定需求客製化UI與行為。

適用情境

  • 資料輸入表單
  • 即時協作編輯
  • 庫存管理系統
  • 財務試算表
  • 互動式儀表板

主要特色

  • 單元格級編輯
  • 可自定樣式
  • 動態行列操作
  • 變更的事件回呼
  • 跨平台支援
  • 內建驗證鈎子

適合對象

  • 開發互動式資料網格的開發者
  • 需要即時資料輸入的應用程式
  • 需要電子試算表功能的專案
  • 致力於跨平台應用的團隊
  • UI密集型的資料視覺化工具

使用建議

  • 處理大型資料集時可能需要效能優化
  • 自定樣式可能會增加開發時間
  • 有限的內建格式選項
  • 需要仔細的狀態管理
  • 不適合靜態只讀表格

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Editable

⚡️A highly customizable, editable table package for Flutter projects.

Specs

pub

This package allows you to create editable tables and spreadsheets with ease, either by providing inital row and column count to display an empty table, or use it with predefined rows and column data sets.

It is compatible with Flutter Desktop (Windows, Linux, MacOS), IOS, Android, and Web. ❤️

Features

  • Save Edited Rows
  • Save Edited cell
  • Customize cell data
  • Add Empty rows
  • Create Empty tables
  • Customizable Save button
  • Customize Table headers
  • Zebra - Stripe table
  • Style table border
  • Adjustable Column widths
Spread Some :heart:

GitHub followers

Support us

You can buy us a cup of coffee. Sponsor our next milestones

Patreon

Getting started

In the pubspec.yaml of your flutter project, add the following dependency:

dependencies:
  ...
  editable: "^1.1.4"

In your library add the following import:

import 'package:editable/editable.dart';

API

Create Table

To create a new table, use the Editable() widget class and provide the table data properties as follows:

  • column: an array of objects example example:

    List cols = [
      {"title":'Name', 'widthFactor': 0.2, 'key':'name'},
      {"title":'Date', 'widthFactor': 0.1, 'key':'date'},
      {"title":'Month', 'widthFactor': 0.1, 'key':'month'},
      {"title":'Status',  'key':'status'},
    ]; 
    

    [title] is the column heading

    [widthFactor] a custom size ratio of each column width, if not provided, defaults to [columnRatio = 0.20] dart 'widthFactor': 0.1 //gives 10% of screen size to the column 'widthFactor': 0.2 //gives 20% of screen size to the column

    [key] an identifyer preferably without space and special characters

  • rows: an array of objects, where each object key represents a column [key], example:

    List rows = [
        {"name": 'James Joe', "date":'23/09/2020',"month":'June',"status":'completed'},
        {"date":'12/4/2020',"month":'March',"name": 'Daniel Paul', "status":'new'},
      ];
    

    Each objects DO NOT have to be positioned in same order as its column

  • rowCount: Interger value of number of rows to be generated: Optional if row data is provided

  • columnCount: Interger value of number of columns to be generated: Optional if column data is provided

  • columnRatio: fraction of the screen width occupied by each column. This is usefull for shrinking and expanding table width example:

      columnRation: 0.2 //sets each column to occupy 20 percent of screen width
    
Customization
  • borderColor: Color of table border

  • borderWidth: width of table borders

  • tdPaddingLeft: Table data cell padding left

  • tdPaddingTop: Table data cell padding top

  • tdPaddingRight: Table data cell padding right;

  • tdPaddingBottom: Table data cell padding bottom;

  • tdAlignment: Aligns the table data ;

  • tdStyle: Style the table data;

  • thPaddingLeft: Table header cell padding left;

  • thPaddingTop: Table header cell padding top;

  • thPaddingRight: Table header cell padding right;

  • thPaddingBottom: Table header cell padding bottom;

  • trHeight: Table Row Height, cannot be less than 40.0 ;

  • thWeight: Table headers fontweight;

  • thSize: Table headers fontSize;

  • tdEditableMaxLines : Max lines allowed in editable text, default: 1 (longer data will not wrap and be hidden), setting to 100 will allow wrapping and not increase row size;

  • showSaveIcon: Toogles the save button, if [true] displays an icon to save rows, adds an addition column to the right

  • saveIcon: Icon for to save row data, example: dart saveIcon : Icons.add

  • saveIconColor: Color for the save Icon

  • saveIconSize: Size for the saveIcon

  • showCreateButton: displays a button that adds a new row onPressed

  • stripeColor1: The first row alternate color, if stripe is set to true

  • stripeColor2: The Second row alternate color, if stripe is set to true;

  • zebraStripe: Enable zebra-striping, set to false by default // if zebraStripe is enabled, you can style the colors [stripeColor1] and [stripeColor2]

  • createButtonAlign: Aligns the button for adding new rows;

  • createButtonIcon: Icon displayed in the create new row button;

  • createButtonColor: Color for the create new row button;

  • createButtonShape: border shape of the create new row button createButtonShape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(8) )

  • createButtonLabel: Label for the create new row button

EditableTheme

Default styles can be supplied using EditableThemeData. Add the theme to ThemeData.extensions or wrap a subtree with EditableTheme:

MaterialApp(
  theme: ThemeData(
    extensions: const [
      EditableThemeData(borderColor: Colors.blueGrey),
    ],
  ),
  home: MyHomePage(),
);

Unset parameters on widgets will fall back to values from the nearest EditableTheme.

Save methods
  • onSubmitted: [onSubmitted] callback is triggered when the enter button is tapped (for desktop users) Or when edit is complete(on mobile) on a table data cell it returns a value of the edited cell data

  • onRowSaved: [onRowSaved] callback is triggered when a [saveButton] is pressed. returns only values if row is edited, otherwise returns a string ['no edit']

  • EditableState key: To get all Edited Rows outside the current context, you can access the editable state using a GlobalKey, example:

         /// Create a Key for EditableState
        final _editableKey = GlobalKey<EditableState>(); 
    
      
        /// Function to add a new row
        /// Using the global key assigined to Editable widget
        /// Access the current state of Editable
        void _addNewRow() {
          setState(() {
            _editableKey.currentState.createRow();
          });
        }
    
        ///Print only edited rows.
        void _printEditedRows() {
          List editedRows = _editableKey.currentState.editedRows;
          print(editedRows);
        }
    
          @override
        Widget build(BuildContext context) {
          return Scaffold(
            appBar: AppBar(
              leadingWidth: 200,
              leading: FlatButton.icon(
                  onPressed: () => _addNewRow(),
                  icon: Icon(Icons.add),
                  label: Text(
                    'Add',
                    style: TextStyle(fontWeight: FontWeight.bold),
                  )),
              title: Text(widget.title),
              actions: [
                Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: FlatButton(
                      onPressed: () => _printEditedRows(),
                      child: Text('Print Edited Rows',
                          style: TextStyle(fontWeight: FontWeight.bold))),
                )
              ],
            ),
            body: Editable(
              key: _editableKey, //Assign Key to Widget
              columns: cols,
              rows: rows,
              zebraStripe: true,
              stripeColor2: Colors.grey[200],
              borderColor: Colors.blueGrey,
            ),
          );
        }
    
    

Screenshots

Editable Table with Data (zebraStripe) Empty SpreadSheet (zebraStripe) Empty SpreadSheet (No Stripe)

Table with Save Icon :-------------:|

Tutorials

The Following are resources to help you build with Editable:

Contribution

I highly encourage the community to step forward and improve this library further. You can fix any reported bug, propose or implement new features, write tests, etc.

Here is a quick list of things to remember

  • Check the open issues before creating a new one,
  • Help me in reducing the number of open issues by fixing any existing bugs,
  • Check the roadmap to see if you can help in implementing any new feature,
  • You can contribute by writing unit and integration tests for this library,
  • If you have any new idea that aligns with the goal of this library, feel free to raise a feature request and discuss it.

Author

This Editable table package for Flutter is developed by Godwin Asuquo

Contributors

CY Uket AmitB Tim Maffet Thumbert ❤️Thank you all for your contributions

Also, as always, please give us a star to help!

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。