搜索插件、代码仓与 APP 分类

cherry_toast 封面
插件详情v1.13.0

cherry_toast

一种在 Flutter 中显示 Toast 的新方式,设计优雅且带有动画效果

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
4340
喜欢数
259
Pub 分数
150

安装插件

flutter pub add cherry_toast

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Cherry Toast 是一个 Flutter 包,提供了一种现代且视觉上吸引人的方法来显示 Toast,具有平滑的动画和可自定义的设计。专为寻求优雅替代标准 Flutter Toast 的开发者而打造,它通过微妙但时尚的反馈提升了用户体验。该包支持 Android、iOS、Web、macOS、Windows 和 Linux 多个平台,确保在各种设备上行为一致。凭借直观的 API 和对美学的关注,Cherry Toast 简化了在 Flutter 应用中集成美观通知的过程。

适合场景

  • 在操作后显示用户反馈
  • 显示成功或错误消息
  • 通过动画通知增强用户界面
  • 提供轻量级状态更新
  • 通过视觉魅力提升应用质感

主要特点

  • 优雅且现代的设计
  • 平滑动画
  • 跨平台支持
  • 可自定义外观
  • 简单 API 集成
  • 支持多种类型的提示

适合对象

  • Flutter 开发者优先考虑 UI 美学
  • 需要完善用户反馈的应用程序
  • 致力于现代通知样式的项目
  • 想要易于使用的吐司解决方案的开发者
  • 专注于用户体验提升的团队

使用建议

  • 可能需要额外的样式以支持深色模式
  • 与功能齐全的通知系统相比,自定义选项有限
  • 依赖外部动画库
  • 不适合复杂的通知工作流
  • 最适合简单、简短的消息

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Cherry Toast


A new way to display toasts in Flutter in an elegant design and animations

info_cherry_toast.gif error_cherry_toast.gif bottom_cherry_toast.gif
warning_cherry_toast.gif success_cherry_toast.gif right_layout_cherry_toast.gif

Cherry Toast

  • Support all platforms
  • Top and Bottom display position
  • Customizable background color
  • Support RTL layout rendering (for arabic text)
  • Multiple built-in themes
  • Built-in animations
  • Support null safety
  • Elegant design
  • Full customizable
  • Heartbeat animation on icons
  • Customizable icon size and color and display
  • Dismissable notification
  • Customizable toast constraints, height and width

Installation

To add cherry toast to your project add this line to your pubspec.yaml file

dependencies:
  cherry_toast: ^1.13.0

Parameters

/// 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
  final Text? action;

  /// 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
  /// this parameter is available in default constructor
  late double iconSize;

  /// The toast display postion, possible values
  /// ```dart
  /// {
  /// 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
  /// ```dart
  /// {
  /// fromTop,
  /// fromLeft,
  /// fromRight
  /// }
  /// ```
  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
  final Duration toastDuration;

  /// The layout of the toast
  /// ```dart
  /// {
  /// ltr,
  /// rtl
  /// }
  /// ```
  final TextDirection textDirection;

  /// Display / Hide the close button icon
  final bool displayCloseButton;

  /// Define the border radius applied on the toast
  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;

  /// The attribute  is declaring a final variable named "width" of type double with a nullable value.
  /// width attribute define the toast width
  final double? width;

  /// The attribute is declaring a final variable named "height" of type double with a nullable type
  /// modifier.
  /// height attribute define the toast height
  final double? height;

  /// Enable taost constraints customization (by default it's null)
  final BoxConstraints? constraints;

  /// Indicate whether the toast animation is enabled or not
  /// by default the toast animation is enabled
  final bool disableToastAnimation;

  /// Indicate toast should inherit theme colors sheme, to apply in background
  /// and shadow color.
  final bool inheritThemeColors;

  /// Callback invoked when toast get dismissed (closed by button or dismissed automtically)
  final Function()? onToastClosed;

  /// Horizontal alignment display of the toast content
  final CrossAxisAlignment horizontalAlignment;

  /// The space rendered between the title and description widgets.
  final double titleDescriptionMargin;

  /// The space rendered between the description and actions widgets.
  final double descriptionActionMargin;

Usage

  • Simple cherry toast with only title

CherryToast.success(

title:  Text("The simplest cherry toast", style: TextStyle(color: Colors.black))

).show(context);



  • Simple cherry toast with action button

CherryToast.info(

title:  Text("User added", style: TextStyle(color: Colors.black)),

action: Text("Display information", style: TextStyle(color: Colors.black)),

actionHandler: (){

print("Action button pressed");

},

).show(context);




A new way to display toasts in Flutter in an elegant design and animations

  • Toast with description without title

CherryToast.warning(

description:  Text("All information may be deleted after this action", style: TextStyle(color: Colors.black)),

animationType:  AnimationType.fromLeft,

action:  Text("Backup data", style: TextStyle(color: Colors.black)),

actionHandler: (){

print("Hello World!!");

},

).show(context);



  • Toast with nothing but description with different animation type and auto dismiss

CherryToast.error(

description:  Text("Invalid account information", style: TextStyle(color: Colors.black)),

animationType:  AnimationType.fromRight,

animationDuration:  Duration(milliseconds:  1000),

autoDismiss:  true

).show(context);



  • Bottom displayed cherry toast

CherryToast(

icon:  Icons.alarm_add,

themeColor:  Colors.pink,

description:  Text("A bottom cherry toast example", style:  TextStyle(color:  Colors.black)),

toastPosition:  Position.bottom,

animationDuration:  Duration(milliseconds:  1000),

autoDismiss:  true

).show(context);


  • Right layout rendered cherry toast

CherryToast(

icon:  Icons.car_repair,

themeColor:  Colors.green,

description: const Text("هذا مثال تصميم من اليمين",  style:  TextStyle(color:  Colors.black)),

toastPosition:  Position.bottom,

layout:  ToastLayout.rtl,

animationType:  AnimationType.fromRight,

action: const Text("انقر هنا", style:  TextStyle(color:  Colors.green)),


animationDuration: const Duration(milliseconds:  1000),

autoDismiss:  true)

.show(context);



Contribution

Of course the project is open source, and you can contribute to it repository link

  • If you found a bug, open an issue.

  • If you have a feature request, open an issue.

  • If you want to contribute, submit a pull request.

Contributors

所属分类

源码仓库

使用此插件的项目

暂无相关数据。