From 820bba9d86a3ed9068187963242d686d4ebe6317 Mon Sep 17 00:00:00 2001 From: Andrea Bizzotto Date: Mon, 15 May 2023 09:44:43 +0100 Subject: [PATCH] Use Navigator.of(context) inside showAlertDialog so MaterialApp.router is not needed in tests # Conflicts: # ecommerce_app/lib/src/common_widgets/alert_dialogs.dart --- ecommerce_app/lib/src/common_widgets/alert_dialogs.dart | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ecommerce_app/lib/src/common_widgets/alert_dialogs.dart b/ecommerce_app/lib/src/common_widgets/alert_dialogs.dart index 192340c8..a5c1aa0d 100644 --- a/ecommerce_app/lib/src/common_widgets/alert_dialogs.dart +++ b/ecommerce_app/lib/src/common_widgets/alert_dialogs.dart @@ -4,7 +4,6 @@ import 'package:ecommerce_app/src/localization/string_hardcoded.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; -import 'package:go_router/go_router.dart'; /// Generic function to show a platform-aware Material or Cupertino dialog Future showAlertDialog({ @@ -28,22 +27,22 @@ Future showAlertDialog({ if (cancelActionText != null) TextButton( child: Text(cancelActionText), - onPressed: () => context.pop(false), + onPressed: () => Navigator.of(context).pop(false), ), TextButton( child: Text(defaultActionText), - onPressed: () => context.pop(true), + onPressed: () => Navigator.of(context).pop(true), ), ] : [ if (cancelActionText != null) CupertinoDialogAction( child: Text(cancelActionText), - onPressed: () => context.pop(false), + onPressed: () => Navigator.of(context).pop(false), ), CupertinoDialogAction( child: Text(defaultActionText), - onPressed: () => context.pop(true), + onPressed: () => Navigator.of(context).pop(true), ), ], ),