简单易用的toast动画,支持iOS和android,支持widget添加,纯flutter,现在有近30种动画可供选择。
中文文档 | English documentation |
---|
dependencies:
flutter_easyhub: ^*.*.*
$ flutter pub get
import 'package:flutter_easyhub/flutter_easy_hub.dart';
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
builder: (ctx, child) =>
FlutterEasyHub(child: MyHomePage(title: 'Flutter Demo Home Page')),
);
}
}
可以开心的使用了😄:
EasyHub.show('loading');
EasyHub.show('loading', duration: Duration(seconds: 2));
///默认2秒消失
EasyHub.showInfoHub('network miss');
///默认2秒消失
EasyHub.showMsg('download success');
///默认2秒消失
EasyHub.showErrorHub('An error occurred');
///默认2秒消失
EasyHub.showCompleteHub('done');
/// 当你仅仅使用动画,那么请使用`EasyHub.dismiss()`来隐藏它。
EasyHub.showHub();
///隐藏
EasyHub.dismiss();
/// 自定义小部件
EasyHub.showCustom(Container(
child: Text('my test'),
));
style:light
maskStyle:dark
style:dark
maskStyle:light
EasyHub.instance.indicatorType = EasyHubIndicatorType.defaultType;
EasyHub.instance
..backgroundColor = Colors.white
..animationForegroundColor = AlwaysStoppedAnimation(Colors.red)
..style = EasyHubStyle.custom;
EasyHub.showHub();
EasyHub.instance
..backgroundColor = Colors.white
..animationForegroundColor = AlwaysStoppedAnimation(Colors.red);
/// only used for maskStyle!= none.
EasyHub.instance.onTap = () {
EasyHub.dismiss();
};
/// 当EasyHubType是 msg可用
String msg;
/// msg的内边框,当是[EasyHubType.all] and [EasyHubType.msg]可用
///
EdgeInsets msgPadding;
/// msg的外边框 ,当[EasyHubType.all] and [EasyHubType.msg]可用
EdgeInsets msgMargin;
/// 自定义文本样式,紧紧[EasyHubStyle.custom]可用
TextStyle textStyle;
/// 文本的颜色,仅仅EasyHubStyle.custom 可用,如果本文设置了textStyle,则被忽略
Color fontColor;
/// 遮罩类型 默认[EasyHubMaskStyle.dark]
EasyHubMaskStyle maskStyle;
/// 展示 动画和msg的类型 默认是都展示
EasyHubStyle style;
/// loading indicator type, default [EasyHubType.all]
/// 动画类型 默认是
EasyHubType _easyHubType;
/// 动画类型
EasyHubIndicatorType indicatorType;
/// 当EasyHubMaskStyle.custom,设置遮罩颜色
Color maskColor;
/// 当EasyHubMaskStyle.custom,设置背景颜色
Color backgroundColor;
/// 动画背景 在大多数[EasyHubIndicatorType]可用,当动画颜色多于2中时,则该参数被忽略
Color animationBackgroundColor;
/// 动画前景色 类型是[Animation<Color>]
/// 当动画颜色多于2中时,则该参数被忽略
Animation<Color> animationForegroundColor;
/// 动画的value范围是[0...1]
/// 仅仅在type是 [EasyHubIndicatorType.lineProgress]可用
/// TODO - [EasyHubIndicatorType.waves]
double progress; //进度条
/// display duration of [showSuccess] [showErrorHub] [showCompleteHub], default 2000ms.
/// 默认展示msg 时间 ,默认是2000ms
Duration displayDuration;
/// 点击消失
/// ```dark
/// EasyHub.instance.onTap = () {
/// EasyHub.dismiss();
/// };
/// ```
GestureTapCallback onTap;
/// display animation duration, default duration is [300ms]
Duration showHubDuration = Duration(milliseconds: 300);
/// hide animation duration, default duration is [300ms]
Duration hideHubDuration = Duration(milliseconds: 300);
/// display animation curve, default curve is [Curves.linear]
Curve showHubCurve = Curves.linear;
/// hide animation curve, default curve is [Curves.linear]
Curve hideHubCurve = Curves.linear;
如果仅仅想使用动画,请看 仔细看下该文件。see detail