app_alert_dialog 0.0.4 copy "app_alert_dialog: ^0.0.4" to clipboard
app_alert_dialog: ^0.0.4 copied to clipboard

A simple customizable alert dialog with two buttons for Flutter apps.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'App Alert Dialog Example',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: HomeScreen(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ElevatedButton(
          onPressed: () {
            _showAlertDialog(context);
          },
          child: Text('Click Me'),
        ),
      ),
    );
  }

  void _showAlertDialog(BuildContext context) {
    AppAlertDialogs.showAlertDialog(
      context: context,
      dialogBodyObject: DialogBodyObject(
        title: 'Error!',
        message: 'Something went wrong!',
      ),
      primaryButton: (pContext) {
        return ElevatedButton(
          onPressed: () {
            Navigator.pop(pContext);
          },
          child: Text('Primary Button'),
        );
      },
      secondaryButton: (sContext) {
        return ElevatedButton(
          onPressed: () {
            Navigator.pop(sContext);
          },
          child: Text('Secondary Button'),
        );
      },
    );
  }
}
2
likes
150
points
27
downloads

Publisher

unverified uploader

Weekly Downloads

A simple customizable alert dialog with two buttons for Flutter apps.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_svg

More

Packages that depend on app_alert_dialog