Last updated:
0 purchases
show custom snackbar
SnackBar is a Flutter widget that enables you to temporarily display a pop-up message and it is used to show lightweight messages
for short time that briefly explain user any action has been occurred in your app.
It usually appears at the bottom of the app’s screen.
For example, you might use the SnackBar widget to let the user know when a selected item has been added to cart or deleted,
or to indicate that a form was sent or an image uploaded successfully.
Features #
Custom snack-bar include the features to show different types of messages with fully customizable features as
show error message with label and title and customizable color.
success message.
warning message.
Getting started #
To use customizable snack-bar call scaffold messenger with show message property and pass custom snack-bar with
customizable values (color, title, icon).
Usage #
class ShowNotification extends StatelessWidget {
const ShowNotification({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.blueGrey.shade500,
appBar: AppBar(
title: const Text('Show Notification'),
),
body: ElevatedButton(
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
content: ShowCustomSnackBar(
title: "Congratulations!",
label: "Your changes have been saved successfully.",
color: Colors.green,
icon: Icons.check_circle_outline,
),
behavior: SnackBarBehavior.floating,
elevation: 0,
backgroundColor: Colors.transparent,
));
},
child: const Text("Success Message")),
);
}
}
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.