ProKitSnackBar class
A versatile widget that displays a custom SnackBar or MaterialBanner with customizable properties such as title, message, colors, icons, and auto-close duration.
The ProKitSnackBar can either be of type ColoredSnackBar or BorderedSnackBar, determined by the snackBarType parameter. It also provides options for positioning, auto-closing, and custom icons through its parameters.
The ProKitNotificationType specifies the type of notification (success, error, warning, etc.), each with its own color and icon. Users can override the default colors or icons by providing their own values.
Example usage:
ProKitSnackBar(
title: 'Success',
message: 'Your action was successful!',
snackBarType: ProKitSnackBarType.colored,
notificationType: ProKitNotificationType.success,
autoClose: true,
autoCloseDuration: Duration(seconds: 3),
).showCustomSnackBar(context);
The inMaterialBanner option can be used to decide whether to display the SnackBar as a MaterialBanner.
ProKitSnackBarPosition can be used to set the SnackBar's position on the screen (e.g., bottom center, top left, etc.).
See also:
- ColoredSnackBar: A colorful SnackBar with optional animations.
- BorderedSnackBar: A bordered SnackBar with a clean look.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- ProKitSnackBar
- Available extensions
Constructors
- ProKitSnackBar.new({Key? key, Color? color, TextStyle? titleTextStyle, TextStyle? messageTextStyle, required String title, required String message, required ProKitSnackBarType snackBarType, required ProKitNotificationType notificationType, bool inMaterialBanner = false, ProKitSnackBarPosition? proKitSnackBarPosition, bool autoClose = true, Duration autoCloseDuration = const Duration(milliseconds: 4000), double? width, double? height, Widget? customIcon})
-
Creates a customizable ProKitSnackBar widget.
const
Properties
- autoClose → bool
-
Whether the SnackBar should auto-close after a duration.
final
- autoCloseDuration → Duration
-
Duration after which the SnackBar will automatically close.
final
- color → Color?
-
Optional background color for the SnackBar.
final
- customIcon → Widget?
-
Custom icon widget displayed in the SnackBar.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- height → double?
-
Optional custom height for the SnackBar.
final
- inMaterialBanner → bool
-
Determines whether the SnackBar should be shown as a MaterialBanner.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- message → String
-
The main message text displayed in the SnackBar.
final
- messageTextStyle → TextStyle?
-
Custom text style for the message.
final
- notificationType → ProKitNotificationType
-
Specifies the notification type (e.g., success, error, warning) that
controls the default color and icon.
final
- proKitSnackBarPosition → ProKitSnackBarPosition?
-
Defines the position of the SnackBar on the screen.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- snackBarType → ProKitSnackBarType
-
Determines the type of the SnackBar, either colored or bordered.
final
- title → String
-
The title text displayed in the SnackBar.
final
- titleTextStyle → TextStyle?
-
Custom text style for the title.
final
- width → double?
-
Optional custom width for the SnackBar.
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's location in the tree.
inherited
-
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
-
isVisible(
bool isVisible) → Widget -
Available on Widget, provided by the VisibilityExtension extension
Shows or hides the widget based onisVisible
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onTap(
VoidCallback onTap) → Widget -
Available on Widget, provided by the WidgetTap extension
Wraps the widget with anInkWell
to provide onTap functionality. -
showCustomSnackBar(
BuildContext context, ProKitSnackBar snackBar) → void - Displays the custom SnackBar in a dialog at the specified position.
-
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
-
wrapWithPadding(
EdgeInsets padding) → Widget -
Available on Widget, provided by the WidgetPadding extension
Wraps the widget with given EdgeInsets padding.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited