preface
Flutter is Google’s mobile UI framework for quickly building high-quality native user interfaces on iOS and Android.
Nicholas Gaulbag, a famous IT expert, once said: The wheel is the ladder of IT progress! Popular frames are the same, with wheels pick one in a million! Flutter, a cross-platform development framework that has been on the rise for the last two years, has a smaller third-party ecosystem than other mature frameworks, but it has a lot of wheels. This series of articles select the wheels commonly used in daily APP development to share, so as to improve the efficiency of brick moving, and hope that the ecology of Flutter will become more and more perfect, with more and more wheels.
This series of articles has been prepared with over 50 wheel recommendations, working for reasons that try to produce an article every 1-2 days.
This series of articles is for those who already have some of the basics of FLUTTER
The body of the
The wheel
- Wheel name: bot_toast
- Overview of wheels: True toasts can be called whenever you need them, with no restrictions (automatically managing context).
- Wheels by [email protected]
- ★★★★★ ★
- ★★★★★
- Effect preview:
The installation
dependencies:
bot_toast: ^ 2.0.0 + 2
Copy the code
import 'package:bot_toast/bot_toast.dart';
Copy the code
An overview of the
-
True toasts can be called whenever you need them, with no restrictions! (This is the most important feature of the Toast library, which is different from other Toast libraries)
-
Rich function, support to display notification, text, loading, attached and other types of Toast
-
Supports popping up various custom Toasts, or you can pop up any Widget as long as it conforms to the requirements of the Flutter code
-
The Api is simple and easy to use, with virtually no required arguments (including BuildContext), which are basically optional
-
The pure flutter implementation is not prone to compatibility problems
use
Initialize BotToast
//1. Wrap the MaterialApp directly with BotToastInit
BotToastInit(
child:MaterialApp(
title: 'BotToast Demo',
navigatorObservers: [BotToastNavigatorObserver()],//2. Register a route observer
home: XxxxPage(),
)
);
Copy the code
Ps: This is one of my favorite points. You can view the route directly from the root of the app, automatically manage the current context, you don’t have to care about the context when you call it, you can call it from anywhere. For example, a toast prompt is displayed for global error interception in the HTTP utility class.
The easiest way to use it
BotToast.showText(text:"xxxx"); // Pop up a text box;
BotToast.showSimpleNotification(title: "init"); // Pop up a simple Toast notification
BotToast.showLoading(); // Pop up a loading animation
// Pop up a positioning 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)); sCopy the code
Customized use
This plugin supports very detailed customization parameters, I will not post too much, see: github.com/MMMzq/bot_t…
Customized renderings:
-
Notification Style customization
-
Customization of Attached Style
-
CustomAnimation Style customization
-
Loading style customization
-
Text Style customization
-
CustomWidget Style customization
At the end
- Address of wheel warehouse: pub.flutter-io.cn/packages/bo…
- Series demo source: github.com/826327700/f…