snackbar_pro 1.0.1 copy "snackbar_pro: ^1.0.1" to clipboard
snackbar_pro: ^1.0.1 copied to clipboard

A beautiful Flutter package that provides animated snackbars with expanding container, custom person figure, and typing text animation.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:snackbar_pro/snackbar_pro.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'SnackBar Pro Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      debugShowCheckedModeBanner: false,
      home: const SnackBarProExample(),
    );
  }
}

class SnackBarProExample extends StatelessWidget {
  const SnackBarProExample({Key? key}) : super(key: key);

  void _showDefaultSnackBar(BuildContext context) {
    SnackBarPro.show(
      context,
      config: const SnackBarProConfig(
        message: "Hello! This is a default SnackBar Pro.",
      ),
    );
  }

  void _showCustomSnackBar(BuildContext context) {
    SnackBarPro.show(
      context,
      config: const SnackBarProConfig(
        message: "This is a custom styled SnackBar Pro!",
        gradientColors: [Colors.orange, Colors.deepOrange],
        typingSpeed: 60,
        containerAnimationDuration: Duration(milliseconds: 1200),
        personFillColor: Colors.yellow,
        personStrokeColor: Colors.red,
        textStyle: TextStyle(
          color: Colors.white,
          fontSize: 18,
          fontWeight: FontWeight.bold,
        ),
      ),
      duration: const Duration(seconds: 8),
    );
  }

  void _showCustomImageSnackBar(BuildContext context) {
    SnackBarPro.show(
      context,
      config: const SnackBarProConfig(
        message: "SnackBar with custom person image!",
        gradientColors: [Colors.green, Colors.teal],
        typingSpeed: 70,
        personImage: AssetImage('assets/demo.png'),
        personSize: Size(60, 80),
        personImageFit: BoxFit.cover,
        personImageBorderRadius: BorderRadius.all(Radius.circular(12)),
        textStyle: TextStyle(
          color: Colors.white,
          fontSize: 16,
          fontWeight: FontWeight.w600,
        ),
      ),
      duration: const Duration(seconds: 7),
    );
  }

  void _showNetworkImageSnackBar(BuildContext context) {
    SnackBarPro.show(
      context,
      config: const SnackBarProConfig(
        message: "Using network image as person figure!",
        gradientColors: [Colors.pink, Colors.purple],
        typingSpeed: 80,
        personImage: NetworkImage('https://img.freepik.com/free-photo/handsome-businessman-white-background_1368-6022.jpg?ga=GA1.1.505319020.1746977396&semt=ais_hybrid&w=740'),
        personSize: Size(55, 75),
        personImageFit: BoxFit.cover,
        personImageBorderRadius: BorderRadius.all(Radius.circular(8)),
      ),
    );
  }

  void _showNoPersonSnackBar(BuildContext context) {
    SnackBarPro.show(
      context,
      config: const SnackBarProConfig(
        message: "This SnackBar Pro has no person figure.",
        showPersonFigure: false,
        gradientColors: [Colors.teal, Colors.cyan],
        typingSpeed: 100,
      ),
    );
  }

  void _showLongMessageSnackBar(BuildContext context) {
    SnackBarPro.show(
      context,
      config: const SnackBarProConfig(
        message: "This is a longer message to demonstrate how the typing animation works with more text content in SnackBar Pro!",
        gradientColors: [Colors.indigo, Colors.purple],
        typingSpeed: 40,
        containerWidthFraction: 0.95,
      ),
      duration: const Duration(seconds: 10),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('SnackBar Pro Examples'),
        backgroundColor: Colors.deepPurple,
        foregroundColor: Colors.white,
        centerTitle: true,
      ),
      body: Center(
        child: Padding(
          padding: const EdgeInsets.all(20.0),
          child: SingleChildScrollView(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                const Text(
                  'SnackBar Pro Examples',
                  style: TextStyle(
                    fontSize: 24,
                    fontWeight: FontWeight.bold,
                    color: Colors.deepPurple,
                  ),
                ),
                const SizedBox(height: 40),
                
                _buildExampleButton(
                  context,
                  'Default SnackBar Pro',
                  'Shows default styling with drawn person figure',
                  () => _showDefaultSnackBar(context),
                  Colors.deepPurple,
                ),
                
                const SizedBox(height: 16),
                
                _buildExampleButton(
                  context,
                  'Custom Styled',
                  'Orange theme with custom animations',
                  () => _showCustomSnackBar(context),
                  Colors.orange,
                ),
                
                const SizedBox(height: 16),
                
                _buildExampleButton(
                  context,
                  'Custom Image (Asset)',
                  'Using custom PNG image from assets',
                  () => _showCustomImageSnackBar(context),
                  Colors.green,
                ),
                
                const SizedBox(height: 16),
                
                _buildExampleButton(
                  context,
                  'Network Image',
                  'Using network image as person figure',
                  () => _showNetworkImageSnackBar(context),
                  Colors.pink,
                ),
                
                const SizedBox(height: 16),
                
                _buildExampleButton(
                  context,
                  'No Person Figure',
                  'SnackBar without person figure',
                  () => _showNoPersonSnackBar(context),
                  Colors.teal,
                ),
                
                const SizedBox(height: 16),
                
                _buildExampleButton(
                  context,
                  'Long Message',
                  'Demonstrates typing with longer text',
                  () => _showLongMessageSnackBar(context),
                  Colors.indigo,
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }

  Widget _buildExampleButton(
    BuildContext context,
    String title,
    String subtitle,
    void Function() onPressed,
    Color color,
  ) {
    return SizedBox(
      width: double.infinity,
      child: ElevatedButton(
        onPressed: onPressed,
        style: ElevatedButton.styleFrom(
          backgroundColor: color,
          foregroundColor: Colors.white,
          padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(12),
          ),
        ),
        child: Column(
          children: [
            Text(
              title,
              style: const TextStyle(
                fontSize: 16,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(height: 4),
            Text(
              subtitle,
              style: const TextStyle(
                fontSize: 12,
                color: Colors.white70,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
4
likes
140
points
48
downloads

Publisher

verified publisheralpha-kraft.blogspot.com

Weekly Downloads

A beautiful Flutter package that provides animated snackbars with expanding container, custom person figure, and typing text animation.

Repository (GitHub)
View/report issues

Topics

#flutter #ui #animation #snackbar #material-design

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on snackbar_pro