From 251dffaf5caa995e322642aa1dfe973f5eaff128 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Tue, 27 Aug 2024 22:00:30 +0200 Subject: [PATCH] fix(neon_framework): Fix login flow not launching URL Signed-off-by: provokateurin --- packages/neon_framework/lib/src/pages/login_flow.dart | 3 +-- packages/neon_framework/lib/src/utils/launch_url.dart | 9 +++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/neon_framework/lib/src/pages/login_flow.dart b/packages/neon_framework/lib/src/pages/login_flow.dart index 0b2e25a5bea..6ac2ae7c433 100644 --- a/packages/neon_framework/lib/src/pages/login_flow.dart +++ b/packages/neon_framework/lib/src/pages/login_flow.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:meta/meta.dart'; -import 'package:neon_framework/models.dart'; import 'package:neon_framework/src/bloc/result.dart'; import 'package:neon_framework/src/blocs/login_flow.dart'; import 'package:neon_framework/src/router.dart'; @@ -39,7 +38,7 @@ class _LoginFlowPageState extends State { initSubscription = bloc.init.listen((result) async { if (result.hasData) { - await launchUrl(NeonProvider.of(context), result.requireData.login); + await launchUrl(null, result.requireData.login); } }); diff --git a/packages/neon_framework/lib/src/utils/launch_url.dart b/packages/neon_framework/lib/src/utils/launch_url.dart index 62b97b0e310..72e2f31f299 100644 --- a/packages/neon_framework/lib/src/utils/launch_url.dart +++ b/packages/neon_framework/lib/src/utils/launch_url.dart @@ -2,9 +2,14 @@ import 'package:neon_framework/models.dart'; import 'package:url_launcher/url_launcher.dart' as url_launcher; /// Completes the [url] using the [account] if necessary and launches it in an external application. -Future launchUrl(Account account, String url) async { +Future launchUrl(Account? account, String url) async { + var uri = Uri.parse(url); + if (account != null) { + uri = account.completeUri(uri); + } + return url_launcher.launchUrl( - account.completeUri(Uri.parse(url)), + uri, mode: url_launcher.LaunchMode.externalApplication, ); }