swift_alert 1.0.0
swift_alert: ^1.0.0 copied to clipboard
Beautiful, customizable notification banners for Flutter.
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'),
),
],
),
),
);
}
}