bot_toast 2.0.0+2

  • Readme
  • Changelog
  • Example
  • Installing
  • 92

BotToast 🤖 #

A really easy to use flutter toast library!

Build Status codecov

Language: English | 中文简体

🐲Overview #

  • In the true sense of Toast, you can call it whenever you need it, without any restrictions! (This is his most important feature, different from other Toast libraries)

  • Feature-rich, support for displaying notifications, text, loading, attachments, etc. Toast

  • Support for popping up various custom Toasts, or you can pop up any Widget as long as it meets the requirements of the flutter code.

  • Api is easy to use, basically has no necessary parameters (including BuildContext), basically all optional parameters

  • Pure flutter implementation, it is not easy to bring compatibility problems

🐼Online Demo #

Online demo (Web effects may be biased, the actual effect is subject to the mobile phone)

🐳Example #

Sample project

🐺Renderings #

NotificationAttachedCustomAnimation
NotificationAttachedCustomAnimation
LoadingTextCustomWidget
LoadingTextCustomWidget

🐮Getting started #

1. add dependencies into you project pubspec.yaml file #

dependencies:
     bot_toast: ^2.0.0

2. import BotToast lib #

import 'package:bot_toast/bot_toast.dart';

3. initialization BotToast #

//1. wrap MaterialApp with BotToastInit
BotToastInit(
  child:MaterialApp(
      title: 'BotToast Demo',
      navigatorObservers: [BotToastNavigatorObserver()],//2.registered route observer
      home: XxxxPage(),
  )
);

4. use BotToast #

BotToast.showText(text:"xxxx");  //popup a text toast;
BotToast.showSimpleNotification(title: "init"); // popup a sample notification toast;
BotToast.showLoading(); //popup a sample loading toast
//popup a attachments toast
BotToast.showAttachedWidget(
    attachedWidget: (_) => Card(
          child: Padding(
            padding: const EdgeInsets.all(8.0),
            child: Icon(
              Icons.favorite,
              color: Colors.redAccent,
            ),
          ),
        ),
    duration: Duration(seconds: 2),
    target: Offset(520, 520));

🐼2.0 version #

Major changes: #

  • Support for custom Toast animation and animation duration

  • Add the showAnimationWidget method, which can be used to highly customize an animated Toast🤩

  • Modified the initialization method to make it more versatile. 1.x version upgrade to 2.0 modification needs manual modification to adapt

  • Remove the reInit method and the two deprecated enumerations PreferDirection.Below and PreferDirection.Upside

  • More detailed version 2.0 changes, click to view

1.x version upgrade to 2.x version #

  • Modify the location used by BotInit, Now wrap your MaterialApp with BotToastInit instead of XxxPage

change:

///1.x.x version initialization method
MaterialApp(
      title: 'BotToast Demo',
      navigatorObservers: [BotToastNavigatorObserver()],
      home: BotToastInit(  
          child: XxxxPage()
      ),
    );

to:

///2.x.x version initialization method
///Wrap your MaterialApp with BotToastInit
BotToastInit(
  child:MaterialApp(
      title: 'BotToast Demo',
      navigatorObservers: [BotToastNavigatorObserver()],
      home: XxxxPage(),
  )
);
  • Modify the warpWidget parameter of the showEnhancedWidget method (note that this step is not necessary, depending on whether you have used showEnhancedWidget, if not used, this step can be omitted)

change:

///1.x.x version
showEnhancedWidget(
  ...
  warpWidget:(widget)=>XxxWrap(child:widget);
  ...
)

to:

///2.x.x version
showEnhancedWidget(
  ...
  warpWidget:(cancel,widget)=>XxxWrap(child:widget);
  ...
)

📃Documentation #

Documentation

[2.0.0+2]

  • Update document

[2.0.0+1]

  • Delete useless print

[2.0.0]

  • 修改初始化的方式,现在更为通用

  • 支持自定义Toast的动画和持续时间😉

  • showEnhancedWidget方法的closeFunc参数其含义已经发生了变化了,现在是等待closeFunc函数执行完毕才移除Toast

  • 添加showAnimationWidget方法,可以使用此方法来高度自定义一个有动画的Toast🤩

  • 移除reInit方法(2.0版本不再需要),以及PreferDirection.BelowPreferDirection.Upside这两个已经被废除的枚举

  • WrapWidget类型方法参数发生变化(破坏性的),但是如果你没有直接使用showEnhancedWidget方式的话,这个修改对1.x版本的代码其实是无影响的,如果有使用请看这里进行兼容1.x版本升级到2.x版本

  • showXxxNotification 添加dismissDirections参数:表示能进行滑动关闭的方向

  • showXxxText,showXxxLoading,showXxxNotification等方法添加了align参数:表示ToastContent区域在MainContent区域的对齐,可用于自定义Toast放置的位置

  • 修复了showAttachedWidget方法的一些bug

  • 支持flutter web(注意不能确保其稳定性)

  • 更新example的样式,并添加了更多demo


  • Modify the way of initialization, now more general

  • Support for custom Toast animation and animation duration😉

  • The meaning of the closeFunc parameter of the showEnhancedWidget method has changed. Now it is wait for the closeFunc function to complete before removing Toast.

  • Add the showAnimationWidget method, you can use this method to highly customize an animated Toast🤩

  • Remove the reInit method and the two deprecated enumerations PreferDirection.Below and PreferDirection.Upside

  • WrapWidget type method parameter changed (not compatible with 1.x version),see 1.x version upgrade 2.x version

  • showXxxNotification Add dismissDirections parameter

  • showXxxText, showXxxLoading, showXxxNotification method adds align parameter

  • Fixed some bugs in the showAttachedWidget method

  • Support flutter web (note that it cannot ensure its stability)

  • Updated the style of example and added more demos

[1.1.1]

  • Bug fix:

The targetContext of the showAttachedWidget method causes a positioning error when it is inside the ScrollView.

showAttachedWidget方法的targetContext在ScrollView里面时导致定位出错

[1.1.0]

  • 主要对showAttachedWidget方法进行了增强,现在支持更多方向,定位更准确了。

  • PreferDirection.BelowPreferDirection.Upside被废弃了,可以改用表达更清晰的topCenter,和bottomCenter来代替,且效果完全一致。这两个枚举将会在下个大版本被删除!

  • showAttachedWidgetpreferDirection 只是期望的方向,实际的位置可能因为空间不足而遭到调整

  • 实际调整顺序可以拿topLeft来进行说明,如果上方空间不足则调整为bottomLeft,然后左边空间不足的话就再判断右边的空间是否充足,充足的话结果为bottomRight,不充足最终结果为bottomCenter

  • 对于preferDirection=xxxCenter的情况,其交叉轴的偏移将会忽略

[1.0.3]

  • 修复当pop所有Route再push Route会出现Bug
  • 加固了当项目使用MaterialApp.navigatorKey,能使用reInit重新初始化

[1.0.2]

  • 放宽init重复初始化检查的程度
  • 替换scheduleFrame方法为ensureVisualUpdate

[1.0.1]

  • Toast关闭后,清理向BotToastNavigatorObserver注册的函数

[1.0.0+2]

  • 更新文档及在线例子

[1.0.0+1]

  • 更新文档及在线例子

[1.0.0]

  • 1.支持弹出Notification Toast
  • 2.支持某个Widget 显示
  • 3.对已有的功能进行重构,增强各个方法

[0.0.2]

  • 添加Loading Toast

[0.0.1]

  • 只是显示Widget到屏幕

example/README.md

example #

cd example
flutter create .
flutter run

Use this package as a library

1. Depend on it

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


dependencies:
  bot_toast: ^2.0.0+2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:bot_toast/bot_toast.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
84
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
92
Learn more about scoring.

We analyzed this package on Oct 18, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/bot_toast.dart.

Run flutter format to format lib/bot_toast.dart.

Format lib/src/basis.dart.

Run flutter format to format lib/src/basis.dart.

Format lib/src/bot_toast_init.dart.

Run flutter format to format lib/src/bot_toast_init.dart.

Fix additional 8 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/key_board_safe_area.dart (Run flutter format to format lib/src/key_board_safe_area.dart.)
  • lib/src/toast.dart (Run flutter format to format lib/src/toast.dart.)
  • lib/src/toast_navigator_observer.dart (Run flutter format to format lib/src/toast_navigator_observer.dart.)
  • lib/src/toast_widget/animation.dart (Run flutter format to format lib/src/toast_widget/animation.dart.)
  • lib/src/toast_widget/loading.dart (Run flutter format to format lib/src/toast_widget/loading.dart.)
  • lib/src/toast_widget/notification.dart (Run flutter format to format lib/src/toast_widget/notification.dart.)
  • lib/src/toast_widget/text.dart (Run flutter format to format lib/src/toast_widget/text.dart.)
  • lib/src/toast_widget/toast_widget.dart (Run flutter format to format lib/src/toast_widget/toast_widget.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test