搜尋套件、儲存庫與 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

原始碼儲存庫

使用此套件的專案

暫無相關資料。