diff --git a/lib/about_page.dart b/lib/about_page.dart index 2acc7b9d..35770e9c 100755 --- a/lib/about_page.dart +++ b/lib/about_page.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:logging/logging.dart'; +import 'package:url_launcher/url_launcher.dart'; import 'app/state.dart'; import 'version.dart'; @@ -25,7 +26,6 @@ class AboutPage extends ConsumerWidget { title: const Text('About'), child: Column( mainAxisSize: MainAxisSize.min, - //crossAxisAlignment: CrossAxisAlignment.start, children: [ Image.asset('assets/graphics/app-icon.png', scale: 1 / 0.75), Padding( @@ -43,17 +43,17 @@ class AboutPage extends ConsumerWidget { const Text(''), Row( mainAxisSize: MainAxisSize.min, - children: const [ + children: [ UrlLink( text: 'Terms of use', - url: - 'https://www.yubico.com/support/terms-conditions/yubico-license-agreement/', + target: Uri.parse( + 'https://www.yubico.com/support/terms-conditions/yubico-license-agreement/'), ), - SizedBox(width: 8.0), + const SizedBox(width: 8.0), UrlLink( text: 'Privacy policy', - url: - 'https://www.yubico.com/support/terms-conditions/privacy-notice/', + target: Uri.parse( + 'https://www.yubico.com/support/terms-conditions/privacy-notice/'), ), ], ), @@ -70,15 +70,16 @@ class AboutPage extends ConsumerWidget { ), Row( mainAxisSize: MainAxisSize.min, - children: const [ + children: [ UrlLink( text: 'Send us feedback', - url: 'https://example.com', + target: Uri.parse('https://example.com'), ), - SizedBox(width: 8.0), + const SizedBox(width: 8.0), UrlLink( - text: 'I need help', - url: 'https://support.yubico.com/support/home'), + text: 'I need help', + target: Uri.parse('https://support.yubico.com/support/home'), + ), ], ), const Padding( @@ -169,9 +170,9 @@ class LoggingPanel extends ConsumerWidget { class UrlLink extends StatefulWidget { final String text; - final String url; + final Uri target; - const UrlLink({super.key, required this.text, required this.url}); + const UrlLink({super.key, required this.text, required this.target}); @override State createState() => _UrlLinkState(); @@ -185,9 +186,8 @@ class _UrlLinkState extends State { super.initState(); _tapRecognizer = TapGestureRecognizer(); _tapRecognizer.onTap = () { - //TODO: use url_launcher - // ignore: avoid_print - print('TODO: Go to ${widget.url}'); + _log.debug('Opening browser to ${widget.target}'); + launchUrl(widget.target, mode: LaunchMode.externalApplication); }; } diff --git a/linux/flutter/generated_plugin_registrant.cc b/linux/flutter/generated_plugin_registrant.cc index 52dbd8dd..8dbd6990 100755 --- a/linux/flutter/generated_plugin_registrant.cc +++ b/linux/flutter/generated_plugin_registrant.cc @@ -7,12 +7,16 @@ #include "generated_plugin_registrant.h" #include +#include #include void fl_register_plugins(FlPluginRegistry* registry) { g_autoptr(FlPluginRegistrar) desktop_drop_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "DesktopDropPlugin"); desktop_drop_plugin_register_with_registrar(desktop_drop_registrar); + g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = + fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); + url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); g_autoptr(FlPluginRegistrar) window_manager_registrar = fl_plugin_registry_get_registrar_for_plugin(registry, "WindowManagerPlugin"); window_manager_plugin_register_with_registrar(window_manager_registrar); diff --git a/linux/flutter/generated_plugins.cmake b/linux/flutter/generated_plugins.cmake index d4fa4f2b..6fb2a09a 100755 --- a/linux/flutter/generated_plugins.cmake +++ b/linux/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST desktop_drop + url_launcher_linux window_manager ) diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 86a97de2..51fbb7f2 100755 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,10 +7,12 @@ import Foundation import desktop_drop import shared_preferences_macos +import url_launcher_macos import window_manager func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { DesktopDropPlugin.register(with: registry.registrar(forPlugin: "DesktopDropPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) + UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) WindowManagerPlugin.register(with: registry.registrar(forPlugin: "WindowManagerPlugin")) } diff --git a/pubspec.lock b/pubspec.lock index 726473e0..86bc4ec5 100755 --- a/pubspec.lock +++ b/pubspec.lock @@ -631,6 +631,62 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.3.0" + url_launcher: + dependency: "direct main" + description: + name: url_launcher + url: "https://pub.dartlang.org" + source: hosted + version: "6.1.2" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.17" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.17" + url_launcher_linux: + dependency: transitive + description: + name: url_launcher_linux + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + url_launcher_macos: + dependency: transitive + description: + name: url_launcher_macos + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" + url_launcher_platform_interface: + dependency: transitive + description: + name: url_launcher_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.5" + url_launcher_web: + dependency: transitive + description: + name: url_launcher_web + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.11" + url_launcher_windows: + dependency: transitive + description: + name: url_launcher_windows + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.1" vector_math: dependency: transitive description: @@ -696,4 +752,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.17.0 <3.0.0" - flutter: ">=2.8.0" + flutter: ">=2.10.0" diff --git a/pubspec.yaml b/pubspec.yaml index c8d80ee7..2495e038 100755 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,6 +49,7 @@ dependencies: qrscanner_zxing: path: android/flutter_plugins/qrscanner_zxing desktop_drop: ^0.3.3 + url_launcher: ^6.1.2 dependency_overrides: analyzer: ^3.4.1 diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 8a0dabf8..cf8e35de 100755 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -7,11 +7,14 @@ #include "generated_plugin_registrant.h" #include +#include #include void RegisterPlugins(flutter::PluginRegistry* registry) { DesktopDropPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("DesktopDropPlugin")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); WindowManagerPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("WindowManagerPlugin")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index a3e8e161..27cf8f20 100755 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -4,6 +4,7 @@ list(APPEND FLUTTER_PLUGIN_LIST desktop_drop + url_launcher_windows window_manager )