Advertisement
fahimkamal63

Alert dialog class

Oct 28th, 2021
1,064
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.47 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. class AlertDialogClass extends StatefulWidget {
  4.   const AlertDialogClass({Key? key}) : super(key: key);
  5.  
  6.   @override
  7.   _AlertDialogClassState createState() => _AlertDialogClassState();
  8. }
  9.  
  10. class _AlertDialogClassState extends State<AlertDialogClass> {
  11.   @override
  12.   Widget build(BuildContext context) {
  13.     return Scaffold(
  14.       appBar: AppBar(
  15.         title: Text("Alert Dialog"),
  16.         centerTitle: true,
  17.       ),
  18.       body: Center(
  19.         child: RaisedButton(
  20.           child: Text("Use Less Button"),
  21.             onPressed: (){
  22.               showDialog(
  23.                   context: context,
  24.                   builder: (BuildContext context){
  25.                     return AlertDialog(
  26.                       title: Text("Alert!!"),
  27.                       content: Text("BOSS is coming."),
  28.                       actions: [
  29.                         FlatButton(
  30.                           child: Text("RUN!!"),
  31.                           onPressed: (){
  32.                             Navigator.pop(context);
  33.                           }
  34.                         ),
  35.                         FlatButton(
  36.                             child: Text("DIE!!"),
  37.                             onPressed: (){
  38.                               Navigator.pop(context);
  39.                             }
  40.                         ),
  41.                       ],
  42.                     );
  43.               });
  44.             }
  45.         ),
  46.       ),
  47.     );
  48.   }
  49.  
  50. }
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement