Advertisement
MELAMOURI

Untitled

May 25th, 2023
796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.29 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. class NewWidget extends StatelessWidget {
  4.   Future<void> showAlertDialog(BuildContext context) async {
  5.     return showDialog<void>(
  6.       context: context,
  7.       barrierDismissible: false, // user must tap button!
  8.       builder: (BuildContext context) {
  9.         return AlertDialog(
  10.           title: const Text('Success Verify'),
  11.           content: SingleChildScrollView(
  12.             child: ListBody(
  13.               children: const <Widget>[
  14.                 Text('Are you sure you want to cancel booking?'),
  15.               ],
  16.             ),
  17.           ),
  18.           actions: <Widget>[
  19.             TextButton(
  20.               child: const Text('No'),
  21.               onPressed: () {
  22.                 Navigator.push(
  23.                   context,
  24.                   MaterialPageRoute(builder: (context) => Home()),
  25.                 );
  26.               },
  27.             ),
  28.           ],
  29.         );
  30.       },
  31.     );
  32.   }
  33.  
  34.   @override
  35.   Widget build(BuildContext context) {
  36.     return Container(
  37.       // Add your widget code here
  38.       // For example, you can use a RaisedButton to trigger the dialog:
  39.       child: RaisedButton(
  40.         onPressed: () {
  41.           showAlertDialog(context);
  42.         },
  43.         child: const Text('Open Dialog'),
  44.       ),
  45.     );
  46.   }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement