feat: launch built-in maps

This commit is contained in:
Rongjian Zhang 2022-10-02 03:34:55 +08:00
parent 4fe46b274a
commit 206cd1244c
8 changed files with 21 additions and 2 deletions

View File

@ -18,6 +18,7 @@ import 'package:git_touch/widgets/user_header.dart';
import 'package:go_router/go_router.dart';
import 'package:gql_github/user.data.gql.dart';
import 'package:gql_github/user.req.gql.dart';
import 'package:maps_launcher/maps_launcher.dart';
import 'package:provider/provider.dart';
class _Repos extends StatelessWidget {
@ -126,8 +127,7 @@ class _User extends StatelessWidget {
prefix: const Icon(Octicons.location),
child: Text(p.location!),
onClick: () {
launchStringUrl(
'https://www.google.com/maps/place/${p.location!.replaceAll(RegExp(r'\s+'), '')}');
MapsLauncher.launchQuery(p.location!);
},
),
if (isNotNullOrEmpty(p.email))

View File

@ -6,10 +6,14 @@
#include "generated_plugin_registrant.h"
#include <maps_launcher/maps_launcher_plugin.h>
#include <sentry_flutter/sentry_flutter_plugin.h>
#include <url_launcher_linux/url_launcher_plugin.h>
void fl_register_plugins(FlPluginRegistry* registry) {
g_autoptr(FlPluginRegistrar) maps_launcher_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "MapsLauncherPlugin");
maps_launcher_plugin_register_with_registrar(maps_launcher_registrar);
g_autoptr(FlPluginRegistrar) sentry_flutter_registrar =
fl_plugin_registry_get_registrar_for_plugin(registry, "SentryFlutterPlugin");
sentry_flutter_plugin_register_with_registrar(sentry_flutter_registrar);

View File

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
maps_launcher
sentry_flutter
url_launcher_linux
)

View File

@ -5,6 +5,7 @@
import FlutterMacOS
import Foundation
import maps_launcher
import package_info_plus_macos
import path_provider_macos
import sentry_flutter
@ -13,6 +14,7 @@ import shared_preferences_macos
import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
MapsLauncherPlugin.register(with: registry.registrar(forPlugin: "MapsLauncherPlugin"))
FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin"))
PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin"))
SentryFlutterPlugin.register(with: registry.registrar(forPlugin: "SentryFlutterPlugin"))

View File

@ -511,6 +511,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
maps_launcher:
dependency: "direct main"
description:
name: maps_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
markdown:
dependency: transitive
description:

View File

@ -72,6 +72,7 @@ dependencies:
google_fonts:
go_router:
from_css_color:
maps_launcher:
antd_mobile:
path: ../ant-design-mobile-flutter

View File

@ -6,10 +6,13 @@
#include "generated_plugin_registrant.h"
#include <maps_launcher/maps_launcher_plugin.h>
#include <sentry_flutter/sentry_flutter_plugin.h>
#include <url_launcher_windows/url_launcher_windows.h>
void RegisterPlugins(flutter::PluginRegistry* registry) {
MapsLauncherPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("MapsLauncherPlugin"));
SentryFlutterPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("SentryFlutterPlugin"));
UrlLauncherWindowsRegisterWithRegistrar(

View File

@ -3,6 +3,7 @@
#
list(APPEND FLUTTER_PLUGIN_LIST
maps_launcher
sentry_flutter
url_launcher_windows
)