搜索插件、代码仓与 APP 分类

dashboard 封面
插件详情v0.0.4

dashboard

动态仪表板小部件,允许您的用户创建自己的布局。支持调整大小、移动、间接调整大小/移动以及自动重新布局。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1530
喜欢数
230
Pub 分数
150

安装插件

flutter pub add dashboard

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

仪表板包提供了一个动态的、用户可配置的小部件,用于构建可自定义布局。用户可以自由调整小部件的大小、移动和重新排列,支持间接调整大小和自动重新布局。非常适合需要交互式自定义的仪表板,可在所有主要平台(包括 Android、iOS、Web、macOS、Windows 和 Linux)上运行。该包专为寻求灵活、响应式 UI 的开发者设计,能够实时适应用户的偏好。

适合场景

  • 可自定义的分析仪表板
  • 用户定义的布局接口
  • 交互式管理面板
  • 实时数据可视化
  • 响应式基于网格的应用程序

主要特点

  • 拖拽式小部件重新定位
  • 可调整大小的控件,支持自动重新布局
  • 间接调整大小/移动支持
  • 跨平台兼容性
  • 动态布局持久化
  • 可配置的网格系统

适合对象

  • 开发交互式仪表板的开发者
  • 需要用户自定义界面的应用程序
  • 具有动态内容网格的项目
  • 专注于用户体验灵活性的前端团队
  • 需要响应式布局的 Web 和移动应用

使用建议

  • 可能需要对大量小部件进行性能优化
  • 初始设置包括配置网格和小部件约束
  • 内置样式选项有限,仅限基本布局
  • 最适合中大型交互式界面
  • 在拖动操作期间需要仔细处理状态管理

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Dynamic dashboard widget that allows your users to create their own layouts. Rezise, move, indirect resize/move, auto re-layout are supported.

Features

Try online demo

Dashboard can be thought of as a dynamic grid. Your users can create their own layouts, add new widgets or remove widgets.

Layout divides the screen into horizontal slots according to the entered value. The aspect ratio of the slots also determine their height. Widgets called DashboardItem are placed in these slots. This layout can be changed later.

Resize

Dashboard Items can be resized both by long pressing on mobile and by holding and moving on desktop/browser.

Move

Dashboard Item locations can be changed by long pressing on mobile or by holding and pulling on desktop/browser.

Slots Changes

With dynamic slot count, you can re-layout window size changes.

>

Storage Delegate

The layout information of the users can be stored in the database or on the local disk.

Define your storage delegate.

class MyItemStorage extends DashboardItemStorageDelegate {  

  @override  
  FutureOr<List<DashboardItem>> getAllItems(int slotCount) {  
    // return items from db.
  }  
  
  @override  
  FutureOr<void> onItemsUpdated(  
      List<DashboardItem> items, int slotCount) {
      // save new layouts to db.
  }
  //[...]
}

And use it.

DashboardItemController.withDelegate(
    itemStorageDelegate: MyItemsStorage())

Getting started

Define Dashboard
Dashboard(  
  dashboardItemController: itemController,  
  itemBuilder: (item) {
	//return widget
  },  
);
Define Items

Items can come from the database, or can be defined as fixed.

Fixed:

DashboardItemController(items: [
  DashboardItem(width: 2, height: 3, identifier: "id_1"),  
  DashboardItem(  
      startX: 3, startY: 4, width: 3, height: 1, identifier: "id_2"),  
]);

Or with delegate:

DashboardItemController<ADashboardItemImp>.withDelegate(  
    itemStorageDelegate: MyItemStorage())

See example

Define Builder

The Builder is invoked with a DashboardItem and returns a widget.

Dashboard(  
  dashboardItemController: itemController,  
  itemBuilder: (item) {
	return Text(item.identifier);
  },  
);

Parameters

Item Style

Each item is wrapped with a Material widget. You can enter the parameters of the Material widget with item style.

All is optional.

ItemStyle(  
  color: Colors.red,  
  borderRadius: BorderRadius.circular(10),  
  shape: const RoundedRectangleBorder(),  
  shadowColor: Colors.black,  
  animationDuration: const Duration(milliseconds: 200),  
  borderOnForeground: false,  
  clipBehavior: Clip.antiAliasWithSaveLayer,  
  elevation: 10,  
  textStyle: const TextStyle(color: Colors.black),  
  type: MaterialType.card  
);
Slide

Slide to top items initially. Auto relayout places items to top as possible.

slideToTop: true

Before:

>

After:

>

Shrink

Shrink items when re-layout or editing is possible.

Edit Mode Settings

See code comments for edit mode settings parameters.

All is optional.

    EditModeSettings(

        // animation settings
        curve: Curves.easeInOutCirc,
        duration: const Duration(milliseconds: 200),
        
        // fill editing item actual size
        fillEditingBackground: true,

        // space that can be held to resize
        resizeCursorSide: 20,
        
        // draw lines for slots
        paintBackgroundLines: true,
        
        // shrink items when editing if possible and necessary
        shrinkOnMove: true,
        
        // long press to edit
        longPressEnabled: true,
        
        // pan to edit
        panEnabled: true,
        
        backgroundStyle: const EditModeBackgroundStyle(
            fillColor: Colors.red,
            lineWidth: 1.5,
            lineColor: Colors.black,
            
            // line by vertical space
            dualLineHorizontal: true,

            // line by horizontal space
            dualLineVertical: true));
Storage Delegate

See example

Additional

"Buy Me A Coffee"

TODO

  • [ ] Define and fix animation bugs.
  • [ ] Check performance improvements.
  • [ ] Write tests.
  • [ ] Add more documentation.
  • [ ] Add more example.
  • [ ] Create Youtube video.

所属分类

源码仓库

使用此插件的项目