dialogx 1.0.0 dialogx: ^1.0.0 copied to clipboard
Dialogs is a Flutter package that provides an easy way to display dialogs and toasts in your Flutter app. With Dialogs, you can save time and effort by avoiding boilerplate code.
import 'package:dialogx/dialogx.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyWidget());
}
class MyWidget extends StatelessWidget {
const MyWidget({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Builder(
builder: (context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: () {
context.showModalDialog(
builder: (context) => AlertDialog(
title: const Text('Alert!'),
content: const Text('Something happened!'),
actions: [
TextButton(
onPressed: () {
Navigator.pop(context);
},
child: const Text('OK'),
),
],
),
);
},
child: const Text('Show Alert'),
),
ElevatedButton(
onPressed: () {
context.showToast('Hello World!');
},
child: const Text('Show Toast'),
),
],
),
),
);
},
),
);
}
}