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

tip_dialog 封面
插件详情v4.0.0

tip_dialog

一个 Flutter 提示对话框

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
241
喜欢数
28
Pub 分数
140

安装插件

flutter pub add tip_dialog

插件介绍

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

一个 Flutter 包,提供可自定义的提示对话框,用于向用户显示简短消息或通知。设计简洁,易于集成,支持 Android、iOS、Web、macOS、Windows 和 Linux 多个平台。该对话框可用于以干净、现代的风格展示有用提示、状态更新或警报。轻量级,非常适合需要最小化、非侵入式反馈机制的应用程序。该包由 inrush.cn 维护,并可通过 pub.dev 获取。

适合场景

  • 显示用户指导提示
  • 显示临时状态消息
  • 提供入门提示
  • 通知用户操作
  • 增强UI反馈

主要特点

  • 跨平台支持
  • 可自定义外观
  • 简单 API
  • 轻量化设计
  • 与 Flutter 应用轻松集成
  • 可配置的持续时间和动画

适合对象

  • 移动和Web应用
  • 引导流程
  • 用户教育功能
  • 极简主义用户界面设计
  • 快速反馈系统

使用建议

  • 仅限基本对话功能
  • 无内置本地化
  • 需要手动处理关闭逻辑
  • 不适用于复杂表单或模态框
  • 最适合短暂且非关键的消息

原始 README

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

TipDialog

  1. Please use 3.0.0 or above version, because earlier versions have serious performance issues
  2. if example no working, please google questions about Flutter upgrade AndroidX, AndroidX Migration - Flutterblock
  3. if run your app, it shows Error: Cannot run with sound null safety, please upgrade version to 4.0.0 Reference

中文版

A Flutter Tip Dialog

Loading Type Dialog Success Tye Dialog Fail Type Dialog
Loading Success Fail
Info Type Dialog Only Icon Dialog Onl Text Dialog
Info OnlyIcon OnlyText
Custom Icon Dialog Custom Body Dialog
CustomIcon CustomBody

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  tip_dialog: ^4.0.0

2. Install it

You can install packages from the command line: with Flutter:

$ flutter packages get

3. Import it

Now in your Dart code, you can use:

import 'package:tip_dialog/tip_dialog.dart';

4. Use

Available attributes
/// [TipDialogContainer]
@required this.child,
/// automatically disappear time
this.duration: const Duration(seconds: 3),
/// mask layer alpha
this.maskAlpha: 0.3
// outside touchable, default false
// if true and onOutsideTouch not set, when use TipDialogHelper.loading(), you can touch mask layer to dismiss
// if true and onOutsideTouch set, when touching the mask layer, onOutsideTouch will be called.
this.outsideTouchable: false
// outside touch callback {@link OutsideTouchCallback}
this.onOutsideTouch
Global Use
/// Use [TipDialogContainer] globally
/// This widget can be globally supported
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'TipDialog Demo',
      theme: new ThemeData(),
      home: Stack(
        children: <Widget>[
          MyHomePage(title: 'TipDialog Demo Home Page'),
          // add [TipDialogContainer] widget here
          TipDialogContainer(duration: const Duration(seconds: 2))
        ],
      ),
    );
  }
}
/// use TipDialogHelper to show or dismiss tip
  Widget build(BuildContext context) {
    return new Scaffold(
        appBar: new AppBar(
          title: new Text(widget.title),
          elevation: 0.5,
        ),
        body: new ListView(children: <Widget>[
          _buildItem("Loading Type Tip Dialog", () async {
            TipDialogHelper.loading("Loading");
            await new Future.delayed(new Duration(seconds: 5));
            TipDialogHelper.dismiss();
          }),
          new Divider(),
          _buildItem("Success Type Tip Dialog", () async {
            TipDialogHelper.success("Loaded Successfully");
          }),
          new Divider(),
          _buildItem("Only text Tip Dialog", () async {
            TipDialogHelper.show(new TipDialog(
              type: TipDialogType.NOTHING,
              tip: "Do Not Repeat",
            ));
          }),
          new Divider(),
          _buildItem("Custom Icon Tip Dialog", () async {
            TipDialogHelper.show(new TipDialog.customIcon(
              icon: new Icon(
                Icons.file_download,
                color: Colors.white,
                size: 30.0,
                textDirection: TextDirection.ltr,
              ),
              tip: "Download",
            ));
          }),
          new Divider(),
          _buildItem("Custom Body Tip Dialog", () async {
            TipDialogHelper.show(new TipDialog.builder(
              bodyBuilder: (context) {
                return new Container(
                  width: 120.0,
                  height: 90.0,
                  alignment: Alignment.center,
                  child: new Text(
                    "Custom",
                    style: new TextStyle(color: Colors.white),
                    /// if TipDialogContainer are outside of MaterialApp,
                    /// here is a must to set
                    textDirection: TextDirection.ltr,
                  ),
                );
              },
              color: Colors.blue.withAlpha(150),
            ));
          }),
          new Divider(),
        ]));
  }

Use a custom widget when using [TipDialogContainer] globally, there may be appear some unexpected errors. such as Text or Icon, will appear similar to the following error.

No Directionality widget found.

Just set TextDirection just fine. See the custom Widget in the example for details.

5. Default Dialog Type

enum TipDialogType { NOTHING, LOADING, SUCCESS, FAIL, INFO }

NOTHING: no icon
LOADING: have a loading icon
SUCCESS: have a success icon
FAIL: have a fail icon
INFO: have a info icon
CUSTOM: custom tip dialog type, just a sign, do nothing

6. TipDialogHelper Method

/// tipDialog: Need to display the widget
///
/// isAutoDismiss: decide whether to disappear automatically, default is true
/// if true, the dialog will not automatically disappear
/// otherwise, the dialog will automatically disappear after the [Duration] set by [TipDialogContainer]
void show(Widget tipDialog, {bool isAutoDismiss: true});

/// dismiss dialog
void dismiss();

/// show info dialog
void info(String tip);
/// show fail dialog
void fail(String errMsg);
/// show success dialog
void success(String success);
/// show loading dialog
void loading(String loadingTip);

See the example directory for more details.

7. Change log

[4.0.0]
  • migrating to null safety
[3.1.0]
  • add outside touchable features
[3.0.0]
  • fix performance issues
  • easier way to call
[2.1.0]
  • add TipDialogHelper and deprecated TipDialogConnector
[2.0.1]
  • fix dismiss bug
  • upgrade android build gradle to 5.1.1
[2.0.0]
  • set default auto dismiss duration as 2 seconds
  • delete [TipDialogContainer] Partial parameters -- show -- outSideTouchable -- defaultTip -- defaultType
  • change show method parameter isLoading to isAutoDismiss
  • force display mask layer
[1.1.2] - (MODIFY)
  • fix infinite call dismiss bug
  • fixed an issue where setting the isLoading value is invalid
[1.1.1] - (MODIFY)
  • fix bugs that occur when using globally
[1.1.0] - (FUNCTION CHANGE)
  • add tip dialog global support
[1.0.1] - (MODIFY).
  • fix loading view version bug.
  • set default loading duration
[1.0.0] - first release.
  • add release.

所属分类

依赖

依赖清单 1 项

  • loading_view^1.1.0

源码仓库

使用此插件的项目

暂无相关数据。