Skip to content

Commit

Permalink
fix(ui_auth): adaptive AlertDialog for Flutter <3.13 (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesnitsky authored Oct 19, 2023
1 parent 537d2b3 commit 0e93d61
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions packages/firebase_ui_shared/lib/src/universal_alert.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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: [
Expand Down

0 comments on commit 0e93d61

Please sign in to comment.