CustomToast class
Render the toast widgets
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CustomToast
Constructors
- CustomToast({Key? key, required IconData icon, required String description, required Color color, String title = '', TextStyle descriptionStyle = const TextStyle(color: Colors.black), TextStyle titleStyle = const TextStyle(color: Colors.black), double width = defaultToastWidth, double height = motionToastHeight, double iconSize = defaultIconSize, bool enableAnimation = true, ORIENTATION layoutOrientation = ORIENTATION.ltr, ANIMATION animationType = ANIMATION.fromBottom, Duration animationDuration = const Duration(milliseconds: 1500), Duration toastDuration = const Duration(seconds: 3), Curve animationCurve = Curves.ease, MOTION_TOAST_POSITION position = MOTION_TOAST_POSITION.bottom, double borderRadius = defaultRadius, Function? onClose, bool dismissable = false})
-
Used to create a custom toast with given
icon
,description
andcolor
- CustomToast.delete({Key? key, required String description, String title = '', TextStyle descriptionStyle = const TextStyle(color: Colors.black), TextStyle titleStyle = const TextStyle(color: Colors.black), ICON_TYPE? iconType = ICON_TYPE.materialDesign, double width = defaultToastWidth, double height = motionToastHeight, double iconSize = defaultIconSize, bool enableAnimation = true, ORIENTATION layoutOrientation = ORIENTATION.ltr, ANIMATION animationType = ANIMATION.fromBottom, Duration animationDuration = const Duration(milliseconds: 1500), Duration toastDuration = const Duration(seconds: 3), Curve animationCurve = Curves.ease, MOTION_TOAST_POSITION position = MOTION_TOAST_POSITION.bottom, double borderRadius = defaultRadius, Function? onClose, bool dismissable = false})
-
Render delete toast
color is set to deleteColor
icon is set to
MOTION_TOAST_ICONS_MD[MOTION_TOAST_TYPE.DELETE]
orMOTION_TOAST_ICONS_CUPERTINO[MOTION_TOAST_TYPE.DELETE]
description
is required - CustomToast.error({Key? key, required String description, String title = '', TextStyle descriptionStyle = const TextStyle(color: Colors.black), TextStyle titleStyle = const TextStyle(color: Colors.black), ICON_TYPE? iconType = ICON_TYPE.materialDesign, double width = defaultToastWidth, double height = motionToastHeight, double iconSize = defaultIconSize, bool enableAnimation = true, ORIENTATION layoutOrientation = ORIENTATION.ltr, ANIMATION animationType = ANIMATION.fromBottom, Duration animationDuration = const Duration(milliseconds: 1500), Duration toastDuration = const Duration(seconds: 3), Curve animationCurve = Curves.ease, MOTION_TOAST_POSITION position = MOTION_TOAST_POSITION.bottom, double borderRadius = defaultRadius, Function? onClose, bool dismissable = false})
-
Render an error toast
color is set to errorColor
icon is set to
MOTION_TOAST_ICONS_MD[MOTION_TOAST_TYPE.ERROR]
orMOTION_TOAST_ICONS_CUPERTINO[MOTION_TOAST_TYPE.ERROR]
description
is required - CustomToast.info({Key? key, required String description, String title = '', TextStyle descriptionStyle = const TextStyle(color: Colors.black), TextStyle titleStyle = const TextStyle(color: Colors.black), ICON_TYPE? iconType = ICON_TYPE.materialDesign, double width = defaultToastWidth, double height = motionToastHeight, double iconSize = defaultIconSize, bool enableAnimation = true, ORIENTATION layoutOrientation = ORIENTATION.ltr, ANIMATION animationType = ANIMATION.fromBottom, Duration animationDuration = const Duration(milliseconds: 1500), Duration toastDuration = const Duration(seconds: 3), Curve animationCurve = Curves.ease, MOTION_TOAST_POSITION position = MOTION_TOAST_POSITION.bottom, double borderRadius = defaultRadius, Function? onClose, bool dismissable = false})
-
Render Info toast
color is set to infoColor
icon is set to
MOTION_TOAST_ICONS_MD[MOTION_TOAST_TYPE.INFO]
orMOTION_TOAST_ICONS_CUPERTINO[MOTION_TOAST_TYPE.INFO]
description
is required - CustomToast.success({Key? key, required String description, String title = '', TextStyle descriptionStyle = const TextStyle(color: Colors.black), TextStyle titleStyle = const TextStyle(color: Colors.black), ICON_TYPE? iconType = ICON_TYPE.materialDesign, double width = defaultToastWidth, double height = motionToastHeight, double iconSize = defaultIconSize, bool enableAnimation = true, ORIENTATION layoutOrientation = ORIENTATION.ltr, ANIMATION animationType = ANIMATION.fromBottom, Duration animationDuration = const Duration(milliseconds: 1500), Duration toastDuration = const Duration(seconds: 3), Curve animationCurve = Curves.ease, MOTION_TOAST_POSITION position = MOTION_TOAST_POSITION.bottom, double borderRadius = defaultRadius, Function? onClose, bool dismissable = false})
-
Render a success toast
color is set to successColor
icon is set to
MOTION_TOAST_ICONS_MD[MOTION_TOAST_TYPE.SUCCESS]
orMOTION_TOAST_ICONS_CUPERTINO[MOTION_TOAST_TYPE.SUCCESS]
description
is required - CustomToast.warning({Key? key, required String description, String title = '', TextStyle descriptionStyle = const TextStyle(color: Colors.black), TextStyle titleStyle = const TextStyle(color: Colors.black), ICON_TYPE? iconType = ICON_TYPE.materialDesign, double width = defaultToastWidth, double height = motionToastHeight, double iconSize = defaultIconSize, bool enableAnimation = true, ORIENTATION layoutOrientation = ORIENTATION.ltr, ANIMATION animationType = ANIMATION.fromBottom, Duration animationDuration = const Duration(milliseconds: 1500), Duration toastDuration = const Duration(seconds: 3), Curve animationCurve = Curves.ease, MOTION_TOAST_POSITION position = MOTION_TOAST_POSITION.bottom, double borderRadius = defaultRadius, Function? onClose, bool dismissable = false})
-
Render a warning toast
color is set to warningColor
icon is set to
MOTION_TOAST_ICONS_MD[MOTION_TOAST_TYPE.WARNING]
orMOTION_TOAST_ICONS_CUPERTINO[MOTION_TOAST_TYPE.WARNING]
description
is required
Properties
- animationCurve → Curve
-
The toast animation curve
by default it's
Curves.ease
final - animationDuration → Duration
-
the Duration of the toast animation
by default it's 1.5 seconds
final
- animationType → ANIMATION
-
The type of animation, by default it's ANIMATION.fromBottom
final
- borderRadius → double
-
Define the border radius of the toast
by default it's 20
final
- color ↔ Color
-
The toast background color
if
motionToastType == MOTION_TOAST_TYPE.CUSTOM
color parameter is required else the color will get the default type color from motionToastColorsgetter/setter pair - description → String
-
String used as a description text
final
- descriptionStyle → TextStyle
-
The text style that will be applied on the description text
final
- dismissable → bool
-
final
- enableAnimation → bool
-
disable or enable the heartbeat animation on the icon
by default the animation is enabled
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double
-
define the height of the toast
final
- icon ↔ IconData
-
The toast icon, for types other than custom
the icon will get the default type icon
getter/setter pair
- iconSize → double
-
the toast icon size
by default it's 40
final
- iconType ↔ ICON_TYPE?
-
The design type icon (Material design or Cupertino)
if motionToastType set to
MOTION_TOAST_TYPE.CUSTOM
iconType will not be used possible valuesgetter/setter pair - key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- layoutOrientation → ORIENTATION
-
The layout orientation (from right to left or from left to right)
final
- motionToastType ↔ MOTION_TOAST_TYPE
-
The toast type possible values:
getter/setter pair
- onClose → Function?
-
Function invoked when the toast is closed
final
- position → MOTION_TOAST_POSITION
-
The position where the toast will be displayed
possible values
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- title → String
-
The title of the toast
if it's empty text it will not be rendered in the widgets
final
- titleStyle → TextStyle
-
The text style that will be applied on the title text
final
- toastDuration → Duration
-
How long the toast will be shown
by default it's 3 seconds.
final
- width → double
-
The toast width by default it's set to 250
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _CustomToastState -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
show(
BuildContext context) → void -
Display the created toast based on the position attribute
context
: the actual context of the application -
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited