FlashNotification class

A widget that displays a notification message on the screen.

Features:

  • Appears temporarily and disappears automatically after a set duration
  • Can be dismissed by tapping on it
  • Customizable appearance (background color, text style, border radius)
  • Supports an optional icon
  • Can be positioned at different locations on the screen
  • Can add a callback to be called when the notification is tapped

Example usage:

FlashNotification.show(
  context: context,
  message: 'Hello, world!',
);

or using the context extension:

context.showFlashNotification(
  message: 'Hello, world!',
);
Inheritance

Constructors

FlashNotification({required String message, required TextStyle textStyle, required BorderRadius radius, Key? key, Color backgroundColor = Colors.black87, Duration duration = const Duration(seconds: 3), Widget? icon, FlashNotificationPosition? position, bool testMode = false, EdgeInsets? padding, void onNotificationTap()?})
Constructor for the FlashNotification widget.
const

Properties

backgroundColor Color
The background color of the notification.
final
duration Duration
The duration of the notification.
final
hashCode int
The hash code for this object.
no setterinherited
icon Widget?
The icon to display in the notification.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
message String
The message to display in the notification.
final
onNotificationTap → void Function()?
The callback to be called when the notification is tapped.
final
padding EdgeInsets?
The padding of the notification.
final
position FlashNotificationPosition?
The position of the notification.
final
radius BorderRadius
The radius of the notification.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
testMode bool
Whether the notification is in test mode.
final
textStyle TextStyle
The text style of the notification.
final

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<FlashNotification>
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
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, int wrapWidth = 65}) 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

Static Methods

hideCurrentNotification() → void
Method to hide the current notification.
show({required BuildContext context, required String message, Color? backgroundColor, TextStyle? textStyle, Duration? duration, Widget? icon, BorderRadius? radius, FlashNotificationPosition? position, EdgeInsets? padding, void onNotificationTap()?, bool testMode = false}) OverlayEntry?
Static method to show a notification.