搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目