google_directions_api
0.10.0, released 3 years ago by thisismarch.dev
Calculates directions between locations using the Google Directions API.
What it does
Calculates directions and routes between locations using the Google Directions API for various modes of transportation. It supports multi-part directions with waypoints, and specifies origins, destinations, and waypoints as text, coordinates, or place IDs.
AI-written summary of version 0.10.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to calculate travel routes and directions using the Google Directions API.
- You want to fetch multi-part directions with waypoints for transit, driving, walking, or cycling.
Skip it when
- You need a solution designed to respond in real time to user input.
- You are looking for an interactive embedded map widget.
Strengths
- Supports multiple modes of transportation including transit, driving, walking, and cycling.
- Handles complex requests with origins, destinations, and waypoints.
Weaknesses
- Not designed to respond in real time to user input.
- Lacks written tests via mocks currently.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
Requires initializing the service with a Google API key using DirectionsService.init('API_KEY').
import 'package:google_directions_api/google_directions_api.dart';
void main() {
DirectionsService.init('API_KEY');
final directionsService = DirectionsService();
final request = DirectionsRequest(
origin: 'New York',
destination: 'San Francisco',
travelMode: TravelMode.driving,
);
directionsService.route(request,
(DirectionsResult response, DirectionsStatus status) {
if (status == DirectionsStatus.ok) {
// do something with successful response
} else {
// do something with error response
}
});
}Alternatives
Packages that do the same job and could replace google_directions_api.
- location_web
Web implementation of the location plugin for Flutter web.
74Compare - geoclue
Dart client for the GeoClue D-Bus geolocation service on Linux.
50Compare - carp_background_location
Background location tracking for Android and iOS using background_locator_2
50Compare - fl_location
Plugin to access device location on Android, iOS, and Web
50Compare
Works with
Packages commonly used together with google_directions_api: ones it builds on, ones built on it, and its own family.