import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; enum DialogUserChoice { firstChoice, secondChoice } Future showChoiceDialog( BuildContext context, String title, String content, { String firstAction = 'ok', String secondAction = 'cancel', }) { AlertDialog alert = AlertDialog( title: Text(title), content: Text(content), actions: [ TextButton( child: Text( firstAction, style: TextStyle( color: Theme.of(context).buttonColor, ), ), onPressed: () { Navigator.of(context, rootNavigator: true).pop(DialogUserChoice.firstChoice); }, ), TextButton( child: Text(secondAction), onPressed: () { Navigator.of(context, rootNavigator: true).pop(DialogUserChoice.secondChoice); }, ), ], ); return showDialog( context: context, builder: (BuildContext context) { return alert; }, barrierColor: Colors.black87, ); }