From 047bce961010ac24b9c4a6aed66865d0a562af00 Mon Sep 17 00:00:00 2001 From: Herwig Birke Date: Mon, 10 Nov 2025 16:42:12 +0100 Subject: [PATCH] android app --- android/app/src/main/AndroidManifest.xml | 4 ++ .../plugins/GeneratedPluginRegistrant.java | 5 ++ ios/Flutter/flutter_export_environment.sh | 8 +-- lib/core/io_open.dart | 29 +++++++- pubspec.lock | 69 +++++++++++++++++++ pubspec.yaml | 3 +- .../flutter/generated_plugin_registrant.cc | 3 + windows/flutter/generated_plugins.cmake | 1 + 8 files changed, 115 insertions(+), 7 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index aeacedd..a94c0f8 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,4 +1,8 @@ + + + + openFolder(String path) async { if (path.isEmpty) return false; try { - if (kIsWeb) return false; + if (kIsWeb) { + final uri = _parseLaunchableUri(path); + if (uri != null) { + return await launchUrl(uri, mode: LaunchMode.platformDefault); + } + return false; + } + if (Platform.isAndroid || Platform.isIOS) { + final uri = _parseLaunchableUri(path); + if (uri != null) { + return await launchUrl(uri, mode: LaunchMode.externalApplication); + } + return false; // Non-HTTP paths (e.g., Windows shares) are not openable on mobile + } if (Platform.isWindows) { await Process.run('explorer', [path]); return true; @@ -24,3 +37,15 @@ Future openFolder(String path) async { return false; } +Uri? _parseLaunchableUri(String input) { + final s = input.trim(); + if (s.isEmpty) return null; + if (s.startsWith('http://') || s.startsWith('https://') || s.startsWith('content://') || s.startsWith('file://')) { + return Uri.tryParse(s); + } + // Allow smb:// or ftp:// if present + if (s.startsWith('smb://') || s.startsWith('ftp://')) { + return Uri.tryParse(s); + } + return null; +} diff --git a/pubspec.lock b/pubspec.lock index 32109d7..f7dd4cb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -155,6 +155,11 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_web_plugins: + dependency: transitive + description: flutter + source: sdk + version: "0.0.0" http: dependency: transitive description: @@ -464,6 +469,70 @@ packages: url: "https://pub.dev" source: hosted version: "1.4.0" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + sha256: "9d06212b1362abc2f0f0d78e6f09f726608c74e3b9462e8368bb03314aa8d603" + url: "https://pub.dev" + source: hosted + version: "6.3.1" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + sha256: "6fc2f56536ee873eeb867ad176ae15f304ccccc357848b351f6f0d8d4a40d193" + url: "https://pub.dev" + source: hosted + version: "6.3.14" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + sha256: "7f2022359d4c099eea7df3fdf739f7d3d3b9faf3166fb1dd390775176e0b76cb" + url: "https://pub.dev" + source: hosted + version: "6.3.3" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + sha256: "4e9ba368772369e3e08f231d2301b4ef72b9ff87c31192ef471b380ef29a4935" + url: "https://pub.dev" + source: hosted + version: "3.2.1" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + sha256: "17ba2000b847f334f16626a574c702b196723af2a289e7a93ffcb79acff855c2" + url: "https://pub.dev" + source: hosted + version: "3.2.2" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + sha256: "552f8a1e663569be95a8190206a38187b531910283c3e982193e4f2733f01029" + url: "https://pub.dev" + source: hosted + version: "2.3.2" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + sha256: "772638d3b34c779ede05ba3d38af34657a05ac55b06279ea6edd409e323dca8e" + url: "https://pub.dev" + source: hosted + version: "2.3.3" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + sha256: "3284b6d2ac454cf34f114e1d3319866fdd1e19cdc329999057e44ffe936cfa77" + url: "https://pub.dev" + source: hosted + version: "3.1.4" uuid: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8e5691b..f449d6a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,6 +13,7 @@ dependencies: dio: ^5.7.0 cached_network_image: ^3.3.1 intl: ^0.19.0 + url_launcher: ^6.3.0 # Material 3 ist im Flutter SDK enthalten @@ -22,4 +23,4 @@ dev_dependencies: flutter_lints: ^5.0.0 flutter: - uses-material-design: true \ No newline at end of file + uses-material-design: true diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8b6d468..4f78848 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,6 +6,9 @@ #include "generated_plugin_registrant.h" +#include void RegisterPlugins(flutter::PluginRegistry* registry) { + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index b93c4c3..88b22e5 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,6 +3,7 @@ # list(APPEND FLUTTER_PLUGIN_LIST + url_launcher_windows ) list(APPEND FLUTTER_FFI_PLUGIN_LIST