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

flutter_smart_dialog 封面
套件詳情v5.3.0

flutter_smart_dialog

一個優雅的 Flutter 對話框解決方案,輕鬆實現 Toast、Loading 和自訂對話框,讓對話框的使用更簡單!

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.4萬
喜歡數
645
Pub 分數
160

安裝套件

flutter pub add flutter_smart_dialog

套件介紹

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

flutter_smart_dialog 是一個輕量級且優雅的 Flutter 套件,旨在簡化對話方塊的實作,包含訊息提示、載入指示器和自訂對話方塊。它提供了一個乾淨且一致的 API,可在多個平台顯示各種類型的彈出式 UI 元件。透過最少的設定與直覺的方法,開發者可快速提升使用者反饋與互動,無需撰寫重複程式碼。此套件支援 Android、iOS、Web、macOS、Windows 與 Linux,非常適合尋求統一對話方塊體驗的跨平台應用程式。

適用情境

  • 顯示吐司通知
  • 在非同步操作期間顯示載入指示器
  • 建立可自訂的對話覆蓋層
  • 實現快速用戶反饋機制
  • 在多螢幕應用程式中管理模態對話方塊

主要特色

  • 簡單直覺的 API
  • 支援彈出提示、載入狀態和自訂對話方塊
  • 跨平台相容性
  • 最小化樣板程式碼
  • 可設定的動畫和主題
  • 與現有 Flutter 項目輕鬆整合

適合對象

  • 開發跨平台 Flutter 應用的開發者
  • 需要一致的UI反饋的團隊
  • 需要輕量級通知解決方案的專案
  • 頻繁用戶互動提示的應用程式
  • 專注於使用者體驗改善的前端開發人員

使用建議

  • 可能需要額外的樣式設定以實現高度自定義的外觀
  • 僅限對話類型UI元件
  • 依賴於 Flutter 的渲染管道
  • 不適合複雜的導航工作流程
  • 最佳搭配其他狀態管理解決方案使用

原始 README

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

pub stars issues commit

Feature and Usage(Must read!):super detailed guide

功能和用法(必看!): 超详细指南


Language: English | 中文

Migrate doc:3.x migrate 4.0 | 3.x 迁移 4.0

Flutter 2:Please use flutter_smart_dialog: 4.2.5

Introduction

An elegant Flutter Dialog solution.

Some Effect

attachLocationAndPoint

attachHighlight

dialogStack

loadingCustom

toastCustom

Advantage

  • Do not need BuildContext

  • Can penetrate dark background, click on the page behind dialog

  • Support dialog stack,close the specified dialog

  • Support positioning widget, display the specified location dialog

  • Support highlight feature,dissolve the specified location mask

  • Easily implement toast,loading,attach dialog,custome dialog,custome notify

Quick start

Install

Initialization

initialization

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage,
      // here
      navigatorObservers: [FlutterSmartDialog.observer],
      // here
      builder: FlutterSmartDialog.init(),
    );
  }
}

Advanced initialization: configure global custom Loading and Toast

SmartDialog's showLoading and showToast provide a default style. Of course, custom param are definitely supported.

  • SmartDialog custom Loading or Toast is very simple: However, when using it, it may make you feel a little troublesome
  • for example
    • Use custom Loading: SmartDialog.showLoading(builder: (_) => CustomLoadingWidget);
    • The effect we want must be like this: SmartDialog.showLoading();
  • In view of the above considerations, I added the function of setting custom default Loading and Toast styles at the entrance

Let me show you the following

  • The entry needs to be configured: implement toastBuilder and loadingBuilder, and pass in custom Toast and Loading
void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomePage,
      // here
      navigatorObservers: [FlutterSmartDialog.observer],
      // here
      builder: FlutterSmartDialog.init(
        //custom default toast widget
        toastBuilder: (String msg) => CustomToastWidget(msg: msg),
        //custom default loading widget
        loadingBuilder: (String msg) => CustomLoadingWidget(msg: msg),
        //custom default notify widget
        notifyStyle: FlutterSmartNotifyStyle(
          successBuilder: (String msg) => CustomSuccessWidget(msg: msg),
          failureBuilder: (String msg) => CustomFailureWidget(msg: msg),
          warningBuilder: (String msg) => CustomWarningWidget(msg: msg),
          alertBuilder: (String msg) => CustomAlertWidget(msg: msg),
          errorBuilder: (String msg) => CustomErrorWidget(msg: msg),
        ),
      ),
    );
  }
}
  • SmartDialog supports default global configuration
SmartDialog.config
  ..custom = SmartConfigCustom(
    maskColor: Colors.black.withOpacity(0.35),
    useAnimation: true,
  )
  ..attach = SmartConfigAttach(
    animationType: SmartAnimationType.scale,
    usePenetrate: false,
  )
  ..loading = SmartConfigLoading(
    clickMaskDismiss: false,
    leastLoadingTime: const Duration(milliseconds: 0),
  )
  ..toast = SmartConfigToast(
    intervalTime: const Duration(milliseconds: 100),
    displayTime: const Duration(milliseconds: 2000),
  );

Easy usage

  • toast usage💬
SmartDialog.showToast('test toast');

toastDefault

  • loading usage⏳
SmartDialog.showLoading();
await Future.delayed(Duration(seconds: 2));
SmartDialog.dismiss(); 

loadingDefault

  • dialog usage🎨
SmartDialog.show(builder: (context) {
  return Container(
    height: 80,
    width: 180,
    decoration: BoxDecoration(
      color: Colors.black,
      borderRadius: BorderRadius.circular(10),
    ),
    alignment: Alignment.center,
    child:
    Text('easy custom dialog', style: TextStyle(color: Colors.white)),
  );
});

dialogEasy

所屬分類

依賴

依賴清單 2 項

原始碼儲存庫

使用此套件的專案