From 4355e3724a095d032121de2f4683b382b3537781 Mon Sep 17 00:00:00 2001 From: Tamara Slosarek Date: Tue, 12 Dec 2023 12:16:58 +0100 Subject: [PATCH] chore(app): create routing utils --- app/lib/common/utilities/module.dart | 1 + app/lib/common/utilities/networking_utils.dart | 13 ------------- app/lib/common/utilities/routing_utils.dart | 12 ++++++++++++ 3 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 app/lib/common/utilities/routing_utils.dart diff --git a/app/lib/common/utilities/module.dart b/app/lib/common/utilities/module.dart index 23567686d..b7529502e 100644 --- a/app/lib/common/utilities/module.dart +++ b/app/lib/common/utilities/module.dart @@ -3,4 +3,5 @@ export 'genome_data.dart'; export 'material_colors.dart'; export 'networking_utils.dart'; export 'platform_utils.dart'; +export 'routing_utils.dart'; export 'string_utils.dart'; diff --git a/app/lib/common/utilities/networking_utils.dart b/app/lib/common/utilities/networking_utils.dart index 78f92fd17..0a4821164 100644 --- a/app/lib/common/utilities/networking_utils.dart +++ b/app/lib/common/utilities/networking_utils.dart @@ -1,7 +1,5 @@ import 'dart:io'; -import '../module.dart'; - Future hasConnectionTo(String host) async { try { final result = await InternetAddress.lookup(host); @@ -10,14 +8,3 @@ Future hasConnectionTo(String host) async { return false; } } - -// Replace whole stack, see https://stackoverflow.com/a/73784156 -Future overwriteRoutes( - BuildContext context, - { required PageRouteInfo nextPage } -) async { - await context.router.pushAndPopUntil( - nextPage, - predicate: (_) => false - ); -} diff --git a/app/lib/common/utilities/routing_utils.dart b/app/lib/common/utilities/routing_utils.dart new file mode 100644 index 000000000..2fe94e68a --- /dev/null +++ b/app/lib/common/utilities/routing_utils.dart @@ -0,0 +1,12 @@ +import '../module.dart'; + +// Replace whole stack, see https://stackoverflow.com/a/73784156 +Future overwriteRoutes( + BuildContext context, + { required PageRouteInfo nextPage } +) async { + await context.router.pushAndPopUntil( + nextPage, + predicate: (_) => false + ); +} \ No newline at end of file