update
This commit is contained in:
@@ -4,6 +4,7 @@ import 'dart:async';
|
|||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
|
||||||
|
import 'package:freecell/utils/http_util.dart';
|
||||||
import 'package:shared_preferences/shared_preferences.dart';
|
import 'package:shared_preferences/shared_preferences.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
// import '../adjust/adjust_service.dart';
|
// import '../adjust/adjust_service.dart';
|
||||||
@@ -29,6 +30,7 @@ Future launchURL(
|
|||||||
String url, {
|
String url, {
|
||||||
LaunchMode mode = LaunchMode.externalApplication,
|
LaunchMode mode = LaunchMode.externalApplication,
|
||||||
}) async {
|
}) async {
|
||||||
|
debugPrint("op $url");
|
||||||
var uri = Uri.parse(url);
|
var uri = Uri.parse(url);
|
||||||
try {
|
try {
|
||||||
await launchUrl(uri, mode: mode);
|
await launchUrl(uri, mode: mode);
|
||||||
@@ -37,13 +39,21 @@ Future launchURL(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String _externalUrlForScheme(String url, String scheme) {
|
String _externalUrlForScheme(String url, String scheme, String? authority) {
|
||||||
final prefix = '$scheme:';
|
// if (authority != null && authority.isNotEmpty) {
|
||||||
if (!url.toLowerCase().startsWith(prefix)) return url;
|
// final urlStr = Uri.decodeComponent(authority);
|
||||||
|
// final uri = Uri.tryParse(urlStr);
|
||||||
|
// if (uri != null && uri.scheme.isNotEmpty) {
|
||||||
|
// return urlStr;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
final prefix = '${scheme.toLowerCase()}://';
|
||||||
|
if (url.length < prefix.length ||
|
||||||
|
url.substring(0, prefix.length).toLowerCase() != prefix) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
final stripped = Uri.decodeComponent(
|
final stripped = Uri.decodeComponent(url.substring(prefix.length));
|
||||||
url.substring(prefix.length).replaceFirst(RegExp(r'^/+'), ''),
|
|
||||||
);
|
|
||||||
|
|
||||||
final uri = Uri.tryParse(stripped);
|
final uri = Uri.tryParse(stripped);
|
||||||
if (uri != null && uri.scheme.isNotEmpty) {
|
if (uri != null && uri.scheme.isNotEmpty) {
|
||||||
@@ -643,9 +653,11 @@ class _LoadingScreenState extends State<LoadingScreen>
|
|||||||
(controller, navigationAction) async {
|
(controller, navigationAction) async {
|
||||||
final requestUrl = navigationAction.request.url
|
final requestUrl = navigationAction.request.url
|
||||||
?.toString();
|
?.toString();
|
||||||
|
|
||||||
if (requestUrl != null &&
|
if (requestUrl != null &&
|
||||||
requestUrl.isNotEmpty) {
|
requestUrl.isNotEmpty) {
|
||||||
_currentWebViewUrl = requestUrl;
|
_currentWebViewUrl = requestUrl;
|
||||||
|
debugPrint('shoule $_currentWebViewUrl');
|
||||||
}
|
}
|
||||||
final requestScheme = navigationAction
|
final requestScheme = navigationAction
|
||||||
.request
|
.request
|
||||||
@@ -667,6 +679,7 @@ class _LoadingScreenState extends State<LoadingScreen>
|
|||||||
_externalUrlForScheme(
|
_externalUrlForScheme(
|
||||||
requestUrl,
|
requestUrl,
|
||||||
requestScheme,
|
requestScheme,
|
||||||
|
navigationAction.request.url?.authority,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return NavigationActionPolicy.CANCEL;
|
return NavigationActionPolicy.CANCEL;
|
||||||
|
|||||||
Reference in New Issue
Block a user