Alert Dialog

import 'package:flutter/material.dart'; 

class MyAlertDialog extends StatefulWidget { 
  @override 
  _MyAlertDialogState createState() => _MyAlertDialogState(); 


class _MyAlertDialogState extends State<MyAlertDialog> { 
  @override 
  Widget build(BuildContext context) { 
    return Scaffold( 
      body: Center( 
        child: ElevatedButton( 
          onPressed: () { 
            showDialog
              context: context, 
              builder: (context) => AlertDialog
                title: const Text("Alert Dialog"), 
                actions: <Widget>[ 
                  TextButton( 
                    child: const Text("ok"), 
                    onPressed: () => Navigator.pop(context), 
                  ), 
                  TextButton( 
                    child: const Text("cancel"), 
                    onPressed: () => Navigator.pop(context), 
                  ), 
                ], 
                content: const Text("Content"), 
              ), 
            ); 
          }, 
          child: const Text("Show Alert Dialog"), 
        ),   ), 
    ); 
  } 
}