Open urls externally on web and desktop platforms as in-app webviews are not working yet

This commit is contained in:
Shawn 2023-09-06 20:09:50 -06:00
parent 3987d8ea7d
commit efc98ee6cc
2 changed files with 15 additions and 4 deletions

View File

@ -1,6 +1,9 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:wonders/common_libs.dart'; import 'package:wonders/common_libs.dart';
import 'package:wonders/logic/common/platform_info.dart';
import 'package:wonders/ui/common/modals/fullscreen_web_view.dart'; import 'package:wonders/ui/common/modals/fullscreen_web_view.dart';
class AboutDialogContent extends StatelessWidget { class AboutDialogContent extends StatelessWidget {
@ -8,7 +11,14 @@ class AboutDialogContent extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
void handleTap(String url) => Navigator.push(context, CupertinoPageRoute(builder: (_) => FullscreenWebView(url))); void handleTap(String url) {
if(PlatformInfo.isDesktopOrWeb){
launchUrl(Uri.parse(url));
} else {
Navigator.push(context, CupertinoPageRoute(builder: (_) => FullscreenWebView(url)));
}
}
List<TextSpan> buildSpan(String text, {Map<String, List<String>>? linkSupplants}) { List<TextSpan> buildSpan(String text, {Map<String, List<String>>? linkSupplants}) {
if (linkSupplants?.isNotEmpty ?? false) { if (linkSupplants?.isNotEmpty ?? false) {

View File

@ -14,6 +14,7 @@ dependencies:
sdk: flutter sdk: flutter
collection: ^1.17.0 collection: ^1.17.0
cupertino_icons: ^1.0.5
desktop_window: ^0.4.0 desktop_window: ^0.4.0
drop_cap_text: ^1.1.3 drop_cap_text: ^1.1.3
equatable: ^2.0.5 equatable: ^2.0.5
@ -28,8 +29,8 @@ dependencies:
gap: ^3.0.1 gap: ^3.0.1
get_it: ^7.2.0 get_it: ^7.2.0
get_it_mixin: ^3.1.4 get_it_mixin: ^3.1.4
google_maps_flutter: ^2.2.3 google_maps_flutter: ^2.5.0
google_maps_flutter_web: ^0.4.0+5 google_maps_flutter_web: ^0.5.4+2
go_router: ^6.5.5 go_router: ^6.5.5
http: ^0.13.5 http: ^0.13.5
image_fade: ^0.6.2 image_fade: ^0.6.2
@ -46,9 +47,9 @@ dependencies:
sized_context: ^1.0.0+1 sized_context: ^1.0.0+1
smooth_page_indicator: ^1.0.1 smooth_page_indicator: ^1.0.1
unsplash_client: ^2.1.0+3 unsplash_client: ^2.1.0+3
url_launcher: ^6.1.14
webview_flutter: ^4.0.2 webview_flutter: ^4.0.2
youtube_player_iframe: ^4.0.4 youtube_player_iframe: ^4.0.4
cupertino_icons: ^1.0.5
dev_dependencies: dev_dependencies:
icons_launcher: ^2.1.3 icons_launcher: ^2.1.3