google_directions_api 0.5.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 95

google_directions_api #

Build Pub GitHub GitHub stars

The Directions API is a service that calculates directions between locations. You can search for directions for several modes of transportation, including transit, driving, walking, or cycling.

Getting Started #

The Directions API is a service that calculates directions between locations using an HTTP request.

With the Directions API, you can:

  • Search for directions for several modes of transportation, including transit, driving, walking or cycling.
  • Return multi-part directions using a series of waypoints.
  • Specify origins, destinations, and waypoints as text strings (e.g. "Chicago, IL" or "Darwin, NT, Australia"), or as latitude/longitude coordinates, or as place IDs.

The API returns the most efficient routes when calculating directions. Travel time is the primary factor optimized, but the API may also take into account other factors such as distance, number of turns and many more when deciding which route is the most efficient.

Note: This service is not designed to respond in real time to user input.

For full info about Directions API visit official documentation

Usage #

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
    }
  });
}

Feature requests and Bug reports #

Feel free to post a feature requests or report a bug here.

TODO #

  • Write tests via mocks

Changelog #

[0.5.0] #

  • Redesigned LatLng, LatLngBounds due to ambiguous class names when using google_maps_flutter or google_maps packages

[0.4.0] #

  • Removed flutter dependency

[0.3.0] #

  • Finished with request models
  • Added LatLng, LatLngBounds to remove dependency on google_maps_flutter plugin
  • Added overviewPath getter for decoded overviewPolyline in DirectionsRoute

[0.2.0] #

  • Redesigned class names of response DTO's
  • Doc updates

[0.1.0] #

  • Implemented DirectionAPI responses
  • Added required request fields (origin/desctination/travelMode)

example/README.md

google_directions_api_example #

Demonstrates how to use the google_directions_api package.

Usage #

import 'package:google_directions_api/google_directions_api.dart';

void main() {
  DirectionsService.init('API_KEY');

  final directinosService = DirectionsService();

  final request = DirectionsRequest(
    origin: 'Chicago, IL',
    destination: 'San Francisco, CA',
    travelMode: TravelMode.driving,
  );

  directinosService.route(request,
      (DirectionsResult response, DirectionsStatus status) {
    if (status == DirectionsStatus.ok) {
      // do something with successful response
    } else {
      // do something with error response
    }
  });
}

Getting Started #

For help getting started with Directions API, view online documentation, which offers tutorials, samples, guidance, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  google_directions_api: ^0.5.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:google_directions_api/google_directions_api.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
90
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
95
Learn more about scoring.

We analyzed this package on Jul 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
flinq ^1.1.1 1.1.1
google_polyline_algorithm ^2.0.0 2.0.0
http ^0.12.0+4 0.12.1
meta ^1.1.8 1.2.2 1.3.0-nullsafety
Transitive dependencies
charcode 1.1.3
collection 1.14.13 1.15.0-nullsafety
http_parser 3.1.4
path 1.7.0
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.2.0 1.3.0-nullsafety
Dev dependencies
pedantic ^1.8.0 1.9.2
test ^1.6.0