swift_alert 1.0.0 copy "swift_alert: ^1.0.0" to clipboard
swift_alert: ^1.0.0 copied to clipboard

Beautiful, customizable notification banners for Flutter.

example/lib/main.dart

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

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

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

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

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

  void _showAlert(BuildContext context, NotificationType type) {
    SwiftAlert.display(
      context,
      message: 'This is a ${type.name} notification!',
      type: type,
      duration: const Duration(seconds: 3),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('SwiftAlert Example')),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            ElevatedButton(
              onPressed: () => _showAlert(context, NotificationType.success),
              child: const Text('Show Success'),
            ),
            ElevatedButton(
              onPressed: () => _showAlert(context, NotificationType.error),
              child: const Text('Show Error'),
            ),
            ElevatedButton(
              onPressed: () => _showAlert(context, NotificationType.info),
              child: const Text('Show Info'),
            ),
            ElevatedButton(
              onPressed: () => _showAlert(context, NotificationType.warning),
              child: const Text('Show Warning'),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
140
points
10
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Beautiful, customizable notification banners for Flutter.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on swift_alert