Below are the looks of various types in package used as Snackbar
🔴 Failure
✅ Success
❔ Help
⚠ Warning
👀 Material Banner Looks
Below are the looks of various types in package used as Snackbar
🔴 Failure
✅ Success
❔ Help
⚠ Warning
💻 Example
Below is a basic example usage of the awesome_snackbar_content
import'package:flutter/material.dart';
import'package:awesome_snackbar_content/awesome_snackbar_content.dart';
classAweseomSnackBarExampleextendsStatelessWidget{
constAweseomSnackBarExample({Key? key}) : super(key: key);
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
ElevatedButton(
child: constText('Show Awesome SnackBar'),
onPressed: () {
final snackBar = SnackBar(
/// need to set following properties for best effect of awesome_snackbar_content
elevation: 0,
behavior: SnackBarBehavior.floating,
backgroundColor: Colors.transparent,
content: AwesomeSnackbarContent(
title: 'On Snap!',
message:
'This is an example error message that will be shown in the body of snackbar!',
/// change contentType to ContentType.success, ContentType.warning or ContentType.help for variants
contentType: ContentType.failure,
),
);
ScaffoldMessenger.of(context)
..hideCurrentSnackBar()
..showSnackBar(snackBar);
},
),
constSizedBox(height: 10),
ElevatedButton(
child: constText('Show Awesome Material Banner'),
onPressed: () {
final materialBanner = MaterialBanner(
/// need to set following properties for best effect of awesome_snackbar_content
elevation: 0,
backgroundColor: Colors.transparent,
forceActionsBelow: true,
content: AwesomeSnackbarContent(
title: 'Oh Hey!!',
message:
'This is an example error message that will be shown in the body of materialBanner!',
/// change contentType to ContentType.success, ContentType.warning or ContentType.help for variants
contentType: ContentType.success,
// to configure for material banner
inMaterialBanner: true,
),
actions: const [SizedBox.shrink()],
);
ScaffoldMessenger.of(context)
..hideCurrentMaterialBanner()
..showMaterialBanner(materialBanner);
},
),
],
),
),
);
}
}
🧑 Credits
This packages has been created in reference to Abu Anwar (GDE Flutter) YouTube video. So, make sure to check his work!