snackbar_extension

Creator: coderz1093

Last updated:

0 purchases

snackbar_extension Image
snackbar_extension Images

Languages

Categories

Add to Cart

Description:

snackbar extension

SnackBar Extension #
A flutter package to provide functions as extension for snackbar.
Show some ❤️ and ⭐ the repo #
Features #
✅ Register Multiple SnackBars
✅ Show registered snackbar anywhere
✅ Show SnackBar till a function runs
✅ Customize snackbar on the fly
Getting started #
Include plugin to your project
dependencies:
snackbar_extension: <latest version>
copied to clipboard
Run pub get and get packages.
Register SnackBars #
The register function registers the snackBar, takes the name of the snackBar and the snackBar itself.
SnackBarExtension.register(
name: "Classic",
snackBar: const SnackBar(
content: Text("Classic"),
),
);
copied to clipboard
Access SnackBar #
The registered snackBars can be accessed through the .of(context, name) function.
SnackBarExtension.of(context, "Classic").show();
copied to clipboard
Customize SnackBar #
SnackBar Extension provides full customization to the registerd snackbars.
SnackBarExtension.of(context, "Modern").setBackgroundColor(Colors.blue);

SnackBarExtension.of(context, "Classic").setContent(const Text("Changed Classic Text"));

SnackBarExtension.of(context, "Modern").setBehavior(SnackBarBehavior.floating);
copied to clipboard
Customization are possible on the fly with snackBar extension.
Show Till #
SnackBar Extension provides showTill function to show a snackbar till a function runs.
SnackBarExtension.of(context, "Modern").showTill(
content: const Text("Show Till Function"),
run: () async {
await Future.delayed(const Duration(seconds: 3));
},
);
copied to clipboard
Example #
Go to example section in pub.dev to see the full example code.
In GitHub, head over to example/lib/main.dart to see the full example code.
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
ElevatedButton(
child: const Text("Register Classic SnackBar"),
onPressed: () {
SnackBarExtension.register(
name: "Classic",
snackBar: const SnackBar(
content: Text("Classic"),
),
);
},
),
ElevatedButton(
child: const Text("Register Modern SnackBar"),
onPressed: () {
SnackBarExtension.register(
name: "Modern",
snackBar: const SnackBar(
content: Text("Modern"),
),
);
},
),
ElevatedButton(
child: const Text("Change Modern Background Color"),
onPressed: () {
SnackBarExtension.of(context, "Modern")
.setBackgroundColor(Colors.blue);
},
),
ElevatedButton(
child: const Text("Show Classic SnackBar"),
onPressed: () {
SnackBarExtension.of(context, "Classic").show();
},
),
ElevatedButton(
child: const Text("Show Modern SnackBar"),
onPressed: () {
SnackBarExtension.of(context, "Modern").show();
},
),
],
),
copied to clipboard
Project Created & Maintained By #
Divyanshu Shekhar #


Contributions #
Contributions are welcomed!
If you feel that a hook is missing, feel free to open a pull-request.
For a custom-hook to be merged, you will need to do the following:


Describe the use-case.


Open an issue explaining why we need this hook, how to use it, ...
This is important as a hook will not get merged if the hook doens't appeal to
a large number of people.


If your hook is rejected, don't worry! A rejection doesn't mean that it won't
be merged later in the future if more people shows an interest in it.
In the mean-time, feel free to publish your hook as a package on https://pub.dev.


A hook will not be merged unles fully tested, to avoid breaking it inadvertendly in the future.


Stargazers #

Forkers #

Copyright & License #
Code and documentation Copyright (c) 2021 DevsOnFlutter. Code released under the BSD 3-Clause License.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.