Info Toast

一个帮助您在应用中无缝创建精美且可自定义的动画吐司和警报的包。

| preview_1.gif | | ————————————————————————————————————————– | ————————————————————————————————————————– | ———————————————————————————————————————————— | | preview_2.gif |

Info Toast

  • 空安全支持

  • 可自定义的位置

  • 可自定义的颜色

  • 内置动画

  • 可关闭的通知

安装

要将 info_toast 添加到您的项目中,请将此行添加到您的 pubspec.yaml 文件中

dependencies:
    info_toast: ^1.0.0

参数

///Text widget displayed as a title in the toast
///required parameter for all toast types
final  Text  title;

///Text widget displayed as a description in the toast
final  Text?  description;

///The action button displayed below description
///by default there's no action added
final  Text?  action;

///indicates whether display or not the title
final  bool  displayTitle;

///the toast icon, it's required when using the default constructor
late  IconData  icon;

///the Icon color
///this parameter is only available on the default constructor
///for the built-in themes the color will be set automatically
late  Color  iconColor;

///background color of container
final  Color  backgroundColor;
///box shadow color of container
final Color shadowColor;
//Custom widget displayed at the place of the predefined icons
final  Widget?  iconWidget;

///the icon size
///by default is 20
///this parameter is available in default constructor
late  double  iconSize;

///the toast display postion, possible values
///{
///top,
///bottom
///}
final  Position  toastPosition;

///The color that will be applied on the circle behind the icon
///for better rendering the action button must have the same color
late  Color  themeColor;

///the function invoked when clicking on the action button
final  Function?  actionHandler;

///The duration of the animation by default it's 1.5 seconds
final  Duration  animationDuration;

///the animation curve by default it's set to `Curves.ease`
final  Cubic  animationCurve;

///The animation type applied on the toast
///{
///fromTop,
///fromLeft,
///fromRight,
///fromBottom,
///}
final  AnimationType  animationType;

///indicates whether the toast will be hidden automatically or not
final  bool  autoDismiss;

///the duration of the toast if [autoDismiss] is true
///by default it's 3 seconds
final  Duration  toastDuration;

  

///the layout of the toast
///{
///ltr,
///rtl
///}
final  ToastLayout  layout;

///Display / Hide the close button icon
///by default it's true
final  bool  displayCloseButton;

///define the border radius applied on the toast
///by default it's 20
final  double  borderRadius;

///Define whether the icon will be rendered or not
final  bool  displayIcon;

///Define wether the animation on the icon will be rendered or not
final  bool  enableIconAnimation;

用法

  • 仅带标题的简单 info_toast

InfoToast.success(

title:  "Hello World!"

).show(context);

  
  • 带操作按钮的简单 info_toast

InfoToast.info(

title:  "User added",

action:  "Display information",

actionHandler: (){

print("Action button pressed");

},

).show(context);

  

一个帮助您在应用中无缝创建精美且可自定义的动画吐司和警报的包。

  • 带描述但不带标题的吐司

InfoToast.warning(

title:  "",

displayTitle:  false,

description:  "All information may be deleted after this action",

animationType:  ANIMATION_TYPE.FROM_TOP,

action:  "Backup data",

actionHandler: (){

print("Hello World!!");

},

).show(context);

  
  • 只有描述的吐司,具有不同的动画类型和自动关闭功能

InfoToast.error(

title:  "",

displayTitle:  false,

description:  "Invalid account information",

animationType:  ANIMATION_TYPE.FROM_RIGHT,

animationDuration:  Duration(milliseconds:  1000),

autoDismiss:  true

).show(context);

  
  • 底部显示的 info_toast

InfoToast(

icon:  Icons.alarm_add,

themeColor:  Colors.pink,

title:  "",

displayTitle:  false,

description:  "A bottom info_toast example",

toastPosition:  POSITION.BOTTOM,

animationDuration:  Duration(milliseconds:  1000),

autoDismiss:  true

).show(context);

  
  • 右侧布局渲染的 info_toast

InfoToast(

icon:  Icon(Icons.car_repair),

themeColor:  Colors.green,

title:  "",

displayTitle:  false,

description:  "هذا مثال تصميم من اليمين",

toastPosition:  POSITION.BOTTOM,

layout:  TOAST_LAYOUT.RTL,

animationType:  ANIMATION_TYPE.FROM_RIGHT,

action:  "انقر هنا",

actionStyle:  TextStyle(color:  Colors.green),

animationDuration:  Duration(milliseconds:  1000),

autoDismiss:  true)

.show(context);

  

贡献

您可以将您的 pull request 发送到 项目仓库

  • 如果您发现了一个 bug,请打开一个 issue。

  • 如果您有功能请求,请打开一个 issue。

  • 如果您想贡献,请提交一个 pull request。

贡献者

灵感

Cherry-Toast

GitHub

查看 Github