Future class Alert Dialog

 import "package:flutter/material.dart";

void main()
{
runApp(MyApp());
}
class MyApp extends StatelessWidget
{
MyApp({super.key});

@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Alert Dialog using Future class",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.teal,
),
home: FirstFuture(),
);
}
}
class FirstFuture extends StatelessWidget
{
FirstFuture({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Alert Dialog using Future Class"),
centerTitle: true,
),
body: Center(
child: ElevatedButton(
onPressed: (){
_dialogBuilder(context);
},
child: const Text("Open Dialog"),
),
),
);
}

Future<void> _dialogBuilder(BuildContext context) {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text("Basic dialog title"),
content: Text("A dialog is a type of modal window that\n appears in front of app content to\n"
"provide critical information, or prompt\n for a decision to be made."),
actions: <Widget>[
TextButton(
onPressed: (){
Navigator.pop(context);
},
child: const Text("Disable"),
),
TextButton(
onPressed: (){
Navigator.pop(context);
},
child: const Text("Enable"),
),
],
);
},
);
}
}

Comments

Popular posts from this blog

Pagination with Bloc Pattern in Flutter

Pagination First Practical in Flutter

ExpansionPanel with ExpansionPanelList with Complete Collapse Operation in Flutter