Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Merge pull request #83 from MXCzkEVM/add_token_handler
Browse files Browse the repository at this point in the history
fix: Launch external links in system default browser
  • Loading branch information
reasje authored Oct 6, 2023
2 parents e49638d + 0c221ac commit 9c17d79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:datadashwallet/features/dapps/subfeatures/open_dapp/widgets/swti
import 'package:datadashwallet/features/dapps/subfeatures/open_dapp/widgets/typed_message_dialog.dart';
import 'package:flutter/services.dart';
import 'package:mxc_logic/mxc_logic.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:web3_provider/web3_provider.dart';
import 'package:web3dart/web3dart.dart';
import 'package:eth_sig_util/util/utils.dart';
Expand Down Expand Up @@ -333,13 +334,14 @@ class OpenDAppPresenter extends CompletePresenter<OpenDAppState> {
);
}

void launchAddress(String address) {
void launchAddress(String address) async {
final chainExplorerUrl = state.network!.explorerUrl!;
final address = state.account!.address;
final addressExplorer = Config.addressExplorer(address);
final launchUri = Formatter.mergeUrl(chainExplorerUrl, addressExplorer);

state.webviewController!.loadUrl(urlRequest: URLRequest(url: launchUri));
if ((await canLaunchUrl(launchUri))) {
await launchUrl(launchUri, mode: LaunchMode.platformDefault);
}
}

bool isAddress(String address) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class SendCryptoPresenter extends CompletePresenter<SendCryptoState> {
final launchUri = Formatter.mergeUrl(chainExplorerUrl, addressExplorer);

if ((await canLaunchUrl(launchUri))) {
await launchUrl(launchUri, mode: LaunchMode.inAppWebView);
await launchUrl(launchUri, mode: LaunchMode.platformDefault);
}
}

Expand Down

0 comments on commit 9c17d79

Please sign in to comment.