From 0e93d6101be1ebaa4b2ee491362fa7a83c71cb58 Mon Sep 17 00:00:00 2001 From: Andrei Lesnitsky Date: Thu, 19 Oct 2023 13:30:51 +0200 Subject: [PATCH] fix(ui_auth): adaptive AlertDialog for Flutter <3.13 (#152) --- .../lib/src/universal_alert.dart | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/packages/firebase_ui_shared/lib/src/universal_alert.dart b/packages/firebase_ui_shared/lib/src/universal_alert.dart index 35e64f73..ab6ecfb1 100644 --- a/packages/firebase_ui_shared/lib/src/universal_alert.dart +++ b/packages/firebase_ui_shared/lib/src/universal_alert.dart @@ -4,8 +4,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:firebase_ui_shared/firebase_ui_shared.dart'; -class UniversalAlert extends StatelessWidget { +class UniversalAlert extends PlatformWidget { final void Function() onConfirm; final void Function() onCancel; @@ -49,8 +50,29 @@ class UniversalAlert extends StatelessWidget { } @override - Widget build(BuildContext context) { - return AlertDialog.adaptive( + Widget buildMaterial(BuildContext context) { + return AlertDialog( + title: Text(title), + content: Text(message), + actions: [ + adaptiveAction( + context: context, + onPressed: onConfirm, + child: Text(confirmButtonText), + isDestructiveAction: true, + ), + adaptiveAction( + context: context, + onPressed: onCancel, + child: Text(cancelButtonText), + ), + ], + ); + } + + @override + Widget buildCupertino(BuildContext context) { + return CupertinoAlertDialog( title: Text(title), content: Text(message), actions: [