Skip to content

Commit

Permalink
fix(neon_framework): Fix login flow not launching URL
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <[email protected]>
  • Loading branch information
provokateurin committed Aug 27, 2024
1 parent 2a48f06 commit 251dffa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/neon_framework/lib/src/pages/login_flow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -39,7 +38,7 @@ class _LoginFlowPageState extends State<LoginFlowPage> {

initSubscription = bloc.init.listen((result) async {
if (result.hasData) {
await launchUrl(NeonProvider.of<Account>(context), result.requireData.login);
await launchUrl(null, result.requireData.login);
}
});

Expand Down
9 changes: 7 additions & 2 deletions packages/neon_framework/lib/src/utils/launch_url.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool> launchUrl(Account account, String url) async {
Future<bool> 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,
);
}

0 comments on commit 251dffa

Please sign in to comment.