Maps launcher for Flutter
A simple package that uses url_launcher to launch the maps app with the proper scheme on all platforms.
On iOS, map links as specified by Apple are launched. On Android, the geo intent is used as documented here. For web and other platforms, the plugin will simply launch Google Maps.
import 'package:maps_launcher/maps_launcher.dart';
...
MapsLauncher.launchQuery('1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA');
MapsLauncher.launchCoordinates(37.4220041, -122.0862462);
Consult the table provided by the url_launcher documentation to see which SDK versions maps_launcher supports.
Run this command:
With Flutter:
$ flutter pub add maps_launcher
This will add a line like this to your package's pubspec.yaml (and run an implicit flutter pub get
):
dependencies:
maps_launcher: ^2.2.0
Alternatively, your editor might support flutter pub get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:maps_launcher/maps_launcher.dart';
import 'package:flutter/material.dart';
import 'package:maps_launcher/maps_launcher.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: Scaffold(
appBar: AppBar(
title: Text(
'Maps Launcher Demo',
),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
ElevatedButton(
onPressed: () => MapsLauncher.launchQuery(
'1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA'),
child: Text('LAUNCH QUERY'),
),
SizedBox(height: 32),
ElevatedButton(
onPressed: () => MapsLauncher.launchCoordinates(
37.4220041, -122.0862462, 'Google Headquarters are here'),
child: Text('LAUNCH COORDINATES'),
),
],
),
),
),
);
}
}
Download details:
Author: byte-sapling.io
Source: https://github.com/pikaju/flutter-maps-launcher