### Show Awesome Snackbar Example Source: https://github.com/mhmzdev/awesome_snackbar_content/blob/main/README.md This example shows how to display a failure-type awesome snackbar. Ensure `elevation` is 0 and `behavior` is `SnackBarBehavior.floating` for the best visual effect. Set `backgroundColor` to `Colors.transparent`. ```dart import 'package:flutter/material.dart'; import 'package:awesome_snackbar_content/awesome_snackbar_content.dart'; class AweseomSnackBarExample extends StatelessWidget { const AweseomSnackBarExample({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ ElevatedButton( child: const Text('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); }, ), const SizedBox(height: 10), ElevatedButton( child: const Text('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); }, ), ], ), ), ); } } ``` -------------------------------- ### Demonstrate All ContentType Variants with AwesomeSnackbarContent Source: https://context7.com/mhmzdev/awesome_snackbar_content/llms.txt This example shows how to display all four `ContentType` variants (failure, success, warning, help) using `AwesomeSnackbarContent`. It requires the parent `SnackBar` to be configured with transparent background and floating behavior. ```dart import 'package:flutter/material.dart'; import 'package:awesome_snackbar_content/awesome_snackbar_content.dart'; class AllTypesDemo extends StatelessWidget { const AllTypesDemo({super.key}); void _show(BuildContext context, ContentType type, String title, String msg) { ScaffoldMessenger.of(context) ..hideCurrentSnackBar() ..showSnackBar( SnackBar( elevation: 0, behavior: SnackBarBehavior.floating, backgroundColor: Colors.transparent, content: AwesomeSnackbarContent( title: title, message: msg, contentType: type, ), ), ); } @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ ElevatedButton( onPressed: () => _show( context, ContentType.failure, 'On Snap!', 'Login failed. Check your credentials.', ), child: const Text('Failure'), ), ElevatedButton( onPressed: () => _show( context, ContentType.success, 'Great!', 'Your profile has been updated.', ), child: const Text('Success'), ), ElevatedButton( onPressed: () => _show( context, ContentType.warning, 'Heads Up!', 'Your session will expire in 5 minutes.', ), child: const Text('Warning'), ), ElevatedButton( onPressed: () => _show( context, ContentType.help, 'Need Help?', 'Visit our support center for assistance.', ), child: const Text('Help'), ), ], ), ), ); } } ``` -------------------------------- ### Import Awesome Snackbar Content Source: https://github.com/mhmzdev/awesome_snackbar_content/blob/main/README.md Import the package in your Flutter project to start using its components. ```dart import 'package:awesome_snackbar_content/awesome_snackbar_content.dart'; ``` -------------------------------- ### RTL Language Support Example Source: https://context7.com/mhmzdev/awesome_snackbar_content/llms.txt The widget automatically supports RTL languages by detecting the ambient `Directionality`. No extra configuration is needed if the app is already wrapped with `Directionality` or uses `MaterialApp` with a locale. ```dart import 'package:flutter/material.dart'; import 'package:awesome_snackbar_content/awesome_snackbar_content.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; class RTLApp extends StatelessWidget { const RTLApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( // Arabic locale enables RTL directionality automatically locale: const Locale('ar'), supportedLocales: const [Locale('ar'), Locale('en')], localizationsDelegates: GlobalMaterialLocalizations.delegates, home: Scaffold( body: Builder( builder: (ctx) => ElevatedButton( onPressed: () { ScaffoldMessenger.of(ctx) ..hideCurrentSnackBar() ..showSnackBar( const SnackBar( elevation: 0, behavior: SnackBarBehavior.floating, backgroundColor: Colors.transparent, content: AwesomeSnackbarContent( title: 'نجاح', message: 'تم حفظ التغييرات بنجاح.', contentType: ContentType.success, ), ), ); }, child: const Text('عرض الإشعار'), ), ), ), ); } } ``` -------------------------------- ### Using DefaultColors for UI Elements Source: https://context7.com/mhmzdev/awesome_snackbar_content/llms.txt Reference the default hex color values used by ContentType variants to build consistent UI elements. This example shows how to use these colors for borders of form fields to match snackbar colors. ```dart import 'package:flutter/material.dart'; import 'package:awesome_snackbar_content/awesome_snackbar_content.dart'; // Reference the same colors used by each ContentType const Color errorBorder = DefaultColors.failureRed; // 0xffc72c41 const Color successBorder = DefaultColors.successGreen; // 0xff2D6A4F const Color warningBorder = DefaultColors.warningYellow; // 0xffFCA652 const Color helpBorder = DefaultColors.helpBlue; // 0xff3282B8 // Example: a form field that turns the same red as a failure snackbar TextField buildErrorField(String errorText) { return TextField( decoration: InputDecoration( enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: errorBorder, width: 2), ), errorText: errorText, ), ); } ``` -------------------------------- ### Display a Failure Snackbar with AwesomeSnackbarContent Source: https://context7.com/mhmzdev/awesome_snackbar_content/llms.txt Use `AwesomeSnackbarContent` as the content for a `SnackBar`. Ensure the parent `SnackBar` has `elevation: 0`, `behavior: SnackBarBehavior.floating`, and `backgroundColor: Colors.transparent` for optimal display. ```dart import 'package:flutter/material.dart'; import 'package:awesome_snackbar_content/awesome_snackbar_content.dart'; // Display a failure snackbar void showFailureSnackBar(BuildContext context) { final snackBar = SnackBar( elevation: 0, behavior: SnackBarBehavior.floating, backgroundColor: Colors.transparent, content: AwesomeSnackbarContent( title: 'On Snap!', message: 'Something went wrong. Please try again later.', contentType: ContentType.failure, ), ); ScaffoldMessenger.of(context) ..hideCurrentSnackBar() ..showSnackBar(snackBar); } ``` -------------------------------- ### Add awesome_snackbar_content to pubspec.yaml Source: https://context7.com/mhmzdev/awesome_snackbar_content/llms.txt Add the package to your pubspec.yaml file to include it in your Flutter project. ```yaml # pubspec.yaml dependencies: flutter: sdk: flutter awesome_snackbar_content: ^0.1.8 ``` -------------------------------- ### Show Snackbar with Custom Typography Source: https://context7.com/mhmzdev/awesome_snackbar_content/llms.txt Fully customize title and message text styles by providing `TextStyle` objects to `titleTextStyle` and `messageTextStyle`. These will completely replace the default white styles. ```dart void showStyledSnackBar(BuildContext context) { final snackBar = SnackBar( elevation: 0, behavior: SnackBarBehavior.floating, backgroundColor: Colors.transparent, content: AwesomeSnackbarContent( title: 'Custom Fonts', message: 'Title is bold serif, message is italic.', contentType: ContentType.success, titleTextStyle: const TextStyle( fontSize: 20, fontWeight: FontWeight.w800, fontFamily: 'Georgia', color: Colors.white, ), messageTextStyle: const TextStyle( fontSize: 13, fontStyle: FontStyle.italic, color: Colors.white70, ), ), ); ScaffoldMessenger.of(context) ..hideCurrentSnackBar() ..showSnackBar(snackBar); } ``` -------------------------------- ### Integrate with MaterialBanner Source: https://context7.com/mhmzdev/awesome_snackbar_content/llms.txt Adapt the widget for use within a `MaterialBanner` by setting `inMaterialBanner: true`. The parent banner must have `elevation: 0`, `backgroundColor: Colors.transparent`, and `forceActionsBelow: true`. The close button automatically calls `hideCurrentMaterialBanner`. ```dart void showMaterialBanner(BuildContext context) { final materialBanner = MaterialBanner( elevation: 0, backgroundColor: Colors.transparent, forceActionsBelow: true, content: AwesomeSnackbarContent( title: 'New Update Available', message: 'Version 2.0 is ready. Tap to install.', contentType: ContentType.warning, inMaterialBanner: true, // required for MaterialBanner mode ), actions: const [SizedBox.shrink()], // required by MaterialBanner API ); ScaffoldMessenger.of(context) ..hideCurrentMaterialBanner() ..showMaterialBanner(materialBanner); } ``` -------------------------------- ### Add Dependency to pubspec.yaml Source: https://github.com/mhmzdev/awesome_snackbar_content/blob/main/README.md Add this dependency to your pubspec.yaml file to include the package in your Flutter project. ```yaml dependencies: flutter: sdk: flutter awesome_snackbar_content: ``` -------------------------------- ### Show Snackbar with Custom Color Source: https://context7.com/mhmzdev/awesome_snackbar_content/llms.txt Override the default snackbar color by passing a `Color` to the `color` parameter. A darker shade for the bubble accent is automatically derived. ```dart void showCustomColorSnackBar(BuildContext context) { final snackBar = SnackBar( elevation: 0, behavior: SnackBarBehavior.floating, backgroundColor: Colors.transparent, content: AwesomeSnackbarContent( title: 'Custom Color', message: 'This snackbar uses a custom purple color.', contentType: ContentType.help, color: const Color(0xff6A0572), // override default blue ), ); ScaffoldMessenger.of(context) ..hideCurrentSnackBar() ..showSnackBar(snackBar); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.