the_flutter_alert 0.0.2 copy "the_flutter_alert: ^0.0.2" to clipboard
the_flutter_alert: ^0.0.2 copied to clipboard

A package to display alert in flutter app

example/lib/main.dart

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

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  _showNotification(String content,
      {FlutterAlertType type = FlutterAlertType.info}) {
    FlutterAlert.showFlutterAlertNotification(
      context,
      content,
      type: FlutterAlertType.success,
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            ElevatedButton(
                onPressed: () {
                  _showNotification('Showing info alert');
                },
                child: const Text('Show info alert')),
            ElevatedButton(
                onPressed: () {
                  _showNotification('Showing success alert',
                      type: FlutterAlertType.success);
                },
                child: const Text('Show success alert')),
            ElevatedButton(
                onPressed: () {
                  _showNotification('Showing error alert',
                      type: FlutterAlertType.error);
                },
                child: const Text('Show error alert')),
            ElevatedButton(
                onPressed: () {
                  _showNotification('Showing warning alert',
                      type: FlutterAlertType.warning);
                },
                child: const Text('Show info alert')),
          ],
        ),
      ),
    );
  }
}
2
likes
120
points
13
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A package to display alert in flutter app

Homepage

License

MIT (license)

Dependencies

flutter

More

Packages that depend on the_flutter_alert