flutter_polyline_points 2.1.0 copy "flutter_polyline_points: ^2.1.0" to clipboard
flutter_polyline_points: ^2.1.0 copied to clipboard

A flutter package to get polyline points by either passing the coordinates or google encoded polyline string

flutter_polyline_points #

A flutter plugin that decodes encoded google polyline string into list of geo-coordinates suitable for showing route/polyline on maps

Getting Started #

This package contains functions to decode google encoded polyline string which returns a list of co-ordinates indicating route between two geographical position

Usage #

To use this package, add flutter_polyline_points as a dependency in your pubspec.yaml file.

Import the package #

import 'package:flutter_polyline_points/flutter_polyline_points.dart';
copied to clipboard

First method #

Get the list of points by Geo-coordinate, this return an instance of PolylineResult, which contains the status of the api, the errorMessage, and the list of decoded points.

PolylinePoints polylinePoints = PolylinePoints();
PolylineResult result = await polylinePoints.getRouteBetweenCoordinates(
        googleApiKey: googleAPiKey,
        request: PolylineRequest(
        origin: PointLatLng(_originLatitude, _originLongitude),
        destination: PointLatLng(_destLatitude, _destLongitude),
        mode: TravelMode.driving,
        wayPoints: [PolylineWayPoint(location: "Sabo, Yaba Lagos Nigeria")],
        ),
);
print(result.points);
copied to clipboard

Second method #

Decode an encoded google polyline string e.g _piFps|U_ulLnnqC_mqNvxq`@

List<PointLatLng> result = polylinePoints.decodePolyline("_p~iF~ps|U_ulLnnqC_mqNvxq`@");
print(result);
copied to clipboard

Third method #

Fetch polyline with alternative routes. This method returns a list of PolylineResult

List<PolylineResult> resulte = await PolylinePoints().getRouteBetweenCoordinates(
      googleApiKey: googleAPiKey,
      request: PolylineRequest(
        origin: PointLatLng(_originLatitude, _originLongitude),
        destination: PointLatLng(_destLatitude, _destLongitude),
        mode: TravelMode.driving,
        wayPoints: [PolylineWayPoint(location: "Sabo, Yaba Lagos Nigeria")],
      ),
    );
print(results.length);
copied to clipboard

See the example directory for a complete sample app

Hint #

kindly ensure you use a valid google api key,
If you need help generating api key for your project click this link

611
likes
150
points
63.1k
downloads

Publisher

verified publishercraftme.dev

Weekly Downloads

2024.08.26 - 2025.03.10

A flutter package to get polyline points by either passing the coordinates or google encoded polyline string

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http

More

Packages that depend on flutter_polyline_points