European Economic Area (EEA) developers
If your billing address is in the European Economic Area, effective on 8 July 2025, the Google Maps Platform EEA Terms of Service will apply to your use of the Services. Functionality varies by region. Learn more.
This repository contains a Flutter plugin that allows users to use the Google Maps Driver SDK for Android and iOS. The plugin has a dependency on the google-maps-navigation plugin.
| Android | iOS | |
|---|---|---|
| Support | SDK 23+ | iOS 16.0+ |
- A Flutter project
- A Google Cloud project with the Navigation SDK enabled, the Maps SDK for iOS enabled and the Local Rides and Deliveries API enabled
- A Google Maps API key from the project above
- Project ID for the project above
- If targeting Android, Google Play Services installed and enabled
- Attributions and licensing text added to your app
Important
Project ID need to be allowlisted before using this plugin. Please contact your Google representative to get your Project ID allowlisted.
- This repository is currently private. You will need to add the package dependency using Git with SSH in the app's
pubspec.yamlfile. See Connecting to GitHub with SSH for instructions on how to provide SSH keys.
dependencies:
google_driver_flutter:
git:
url: git@github.com:googlemaps/flutter-driver-sdk.git
-
Follow the instructions at the
google_navigation_flutterplugin Readme to add your API key to the appropriate files in your Flutter project.
Before initializing the delivery or the ridesharing driver, you must initialize the navigation session.
import 'package:flutter/material.dart';
import 'package:google_driver_flutter/google_driver_flutter.dart';
import 'package:google_navigation_flutter/google_navigation_flutter.dart';
class DeliveryDriverSample extends StatefulWidget {
const DeliveryDriverSample({super.key});
@override
State<DeliveryDriverSample> createState() => _DeliveryDriverSampleState();
}
class _DeliveryDriverSampleState extends State<DeliveryDriverSample> {
String _providerId = "Your Google Maps Platform Provider ID";
String _vehicleId = "Delivery Vehicle ID"; // Get vehicle ID from your backend
@override
void initState() {
super.initState();
_initialize();
}
Future<void> _initialize() async {
if (!await GoogleMapsNavigator.areTermsAccepted()) {
await GoogleMapsNavigationManager.showTermsAndConditionsDialog(
'Example title',
'Example company',
);
}
// Note: make sure user has also granted location permissions before starting navigation session.
await GoogleMapsNavigator.initializeNavigationSession();
// Initialize delivery driver.
await DeliveryDriver.initialize(
providerId: _providerId,
vehicleId: _vehicleId,
onGetToken: (AuthTokenContext context) async {
final String token = "token" // Get token from your backend
return token;
});
// Enable location tracking.
await DeliveryDriver.vehicleReporter
.setLocationTrackingEnabled(true);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Google Maps Delivery Driver Sample')),
body: GoogleMapsNavigationView(
onViewCreated: _onViewCreated,
),
);
}
...
@override
void dispose() {
...
DeliveryDriver.dispose();
GoogleMapsNavigator.cleanup();
...
super.dispose();
}
}See the example directory for a complete delivery driver sample app.
import 'package:flutter/material.dart';
import 'package:google_driver_flutter/google_driver_flutter.dart';
import 'package:google_navigation_flutter/google_navigation_flutter.dart';
class RidesharingDriverSample extends StatefulWidget {
const RidesharingDriverSample({super.key});
@override
State<RidesharingDriverSample> createState() => _RidesharingDriverSampleState();
}
class _RidesharingDriverSampleState extends State<RidesharingDriverSample> {
String _providerId = "Your Google Maps Platform Provider ID";
String _vehicleId = "Ridesharing Vehicle ID"; // Get vehicle ID from your backend
@override
void initState() {
super.initState();
_initialize();
}
Future<void> _initialize() async {
if (!await GoogleMapsNavigator.areTermsAccepted()) {
await GoogleMapsNavigationManager.showTermsAndConditionsDialog(
'Example title',
'Example company',
);
}
// Note: make sure user has also granted location permissions before starting navigation session.
await GoogleMapsNavigator.initializeNavigationSession();
// Initialize ridesharing driver.
await RidesharingDriver.initialize(
providerId: _providerId,
vehicleId: _vehicleId,
onGetToken: (AuthTokenContext context) async {
final String token = "token" // Get token from your backend
return token;
});
// Enable location tracking.
await RidesharingDriver.vehicleReporter
.setLocationTrackingEnabled(true);
// After location tracking is enabled, the vehicle state can be set to online.
await RidesharingDriver.vehicleReporter
.setVehicleState(RidesharingVehicleState.online);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Google Maps Ridesharing Driver Sample')),
body: GoogleMapsNavigationView(
onViewCreated: _onViewCreated,
),
);
}
...
@override
void dispose() {
...
RidesharingDriver.dispose();
GoogleMapsNavigator.cleanup();
...
super.dispose();
}
}See the example directory for a complete ridesharing driver sample app.
See the Contributing guide.
This package uses Google Maps Platform services, and any use of Google Maps Platform is subject to the Terms of Service.
For clarity, this package, and each underlying component, is not a Google Maps Platform Core Service.
This package is offered via an open source license. It is not governed by the Google Maps Platform Support Technical Support Services Guidelines, the SLA, or the Deprecation Policy (however, any Google Maps Platform services used by the library remain subject to the Google Maps Platform Terms of Service).
This package adheres to semantic versioning to indicate when backwards-incompatible changes are introduced. Accordingly, while the library is in version 0.x, backwards-incompatible changes may be introduced at any time.
If you find a bug, or have a feature request, please file an issue on GitHub. If you would like to get answers to technical questions from other Google Maps Platform developers, ask through one of our developer community channels. If you'd like to contribute, please check the Contributing guide.