Skip to main content

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

A simple Flutter package for success and error snackbars.

example/lib/main.dart

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

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

class ExampleApp extends StatelessWidget {
  const ExampleApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "Snackbar Alert Example",
      theme: ThemeData(primarySwatch: Colors.blue),
      home: const ExampleHomePage(),
    );
  }
}

class ExampleHomePage extends StatelessWidget {
  const ExampleHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Snackbar Alert Demo")),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            // ✅ Success
            ElevatedButton(
              onPressed: () {
                SnackBarAlert.show(
                  context,
                  "Profile updated!",
                  type: SnackBarType.success,
                );
              },
              child: const Text("Show success Snackbar"),
            ),
            const SizedBox(height: 20),
            // ❌ Error
            ElevatedButton(
              onPressed: () {
                SnackBarAlert.show(
                  context,
                  "Something went wrong!",
                  type: SnackBarType.error,
                  leftWidget: Icon(Icons.error),
                  rightWidget: TextButton(
                    onPressed: () => print("Undo pressed"),
                    child: const Text(
                      "UNDO",
                      style: TextStyle(color: Colors.black),
                    ),
                  ),
                );
              },
              child: const Text("Show error Snackbar"),
            ),
            const SizedBox(height: 20),
            // ⚠️ Warning
            ElevatedButton(
              onPressed: () {
                SnackBarAlert.show(
                  context,
                  "Low battery warning!",
                  type: SnackBarType.warning,
                );
              },
              child: const Text("Show warning Snackbar"),
            ),
            const SizedBox(height: 20),
            // ℹ️ Info
            ElevatedButton(
              onPressed: () {
                SnackBarAlert.show(
                  context,
                  "New version available",
                  type: SnackBarType.info,
                );
              },
              child: const Text("Show info Snackbar"),
            ),
            const SizedBox(height: 20),
            // 💬 Normal0
            ElevatedButton(
              onPressed: () {
                SnackBarAlert.show(
                  context,
                  "Welcome back!",
                  type: SnackBarType.normal,
                );
              },
              child: const Text("Show normal Snackbar"),
            ),

            const SizedBox(height: 20),
            // 📊 showProgress
            ElevatedButton(
              onPressed: () {
                SnackBarAlert.showProgress(context, "Uploading file...");
              },
              child: const Text("Show showProgress Snackbar"),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
160
points
11
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A simple Flutter package for success and error snackbars.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on snackbar_alert