showBinaryDialog function

Future<bool?> showBinaryDialog(
  1. BuildContext context,
  2. Widget title,
  3. Widget content, {
  4. required String positiveText,
  5. required String negativeText,
})

Shows a AlertDialog with two actions buttons, negative and positive, that respectively pops either false or true.

The texts of these action buttons can be changed using positiveText and negativeText.

Implementation

Future<bool?> showBinaryDialog(
  f.BuildContext context,
  f.Widget title,
  f.Widget content, {
  required String positiveText,
  required String negativeText,
}) async {
  return await f.showDialog(
    context: context,
    builder: (context) {
      return f.AlertDialog(
        title: title,
        content: content,
        actions: [
          f.TextButton(
            onPressed: () => context.pop(false),
            child: f.Text(negativeText),
          ),
          f.TextButton(
            onPressed: () => context.pop(true),
            child: f.Text(positiveText),
          ),
        ],
      );
    },
  );
}