Skip to content
pubscout

google_directions_api

0.10.0, released 3 years ago by thisismarch.dev

Calculates directions between locations using the Google Directions API.

WASM-ready
$ flutter pub add google_directions_api
Source repository

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.

Works with

Packages commonly used together with google_directions_api: ones it builds on, ones built on it, and its own family.