maps_curved_line 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 79

maps_curved_line #

pub package

A package to help draw curved lines on Google Maps. Generates a list of LatLng which can be used to render a curved polyline between the given start and end LatLng.

Installation #

First, add maps_curved_lines as a dependency in your pubspec.yaml file.

Usage: #

import 'package:maps_curved_line/maps_curved_line.dart';
.
.

class _MapsPageState extends State<MapsPage> {

  final Set<Polyline> _polylines = Set();

  final LatLng _point1 = LatLng(12.947437, 77.681345);
  final LatLng _point2 = LatLng(12.948767, 77.689120);

  @override
  Widget build(BuildContext context) {
    _polylines.add(
        Polyline(
            polylineId: PolylineId("line 1"),
            visible: true,
            width: 2,
            //latlng is List<LatLng>
            patterns: [PatternItem.dash(30), PatternItem.gap(10)],
            points: MapsCurvedLines.getPointsOnCurve(_point1, _point2), // Invoke lib to get curved line points
            color: Colors.blue,
        )
    );

    return new Scaffold(
      body: GoogleMap(
        // Configure google maps widget are required
        .
        polylines: _polylines, // Add constructed polyline for curved line
        .
        .
      ),
    );
  }
}

[0.1.1] #

Add public screenshots to README

[0.1.0] #

Fix iOS example code and mark as stable. Add screenshots to README

[0.0.2] #

Improve package score by fixing hints and adding more description.

[0.0.1] #

Initial Release

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:maps_curved_line/maps_curved_line.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Maps Curved Lines Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
      ),
      home: MapsPage(),
    );
  }
}

class MapsPage extends StatefulWidget {
  @override
  _MapsPageState createState() => _MapsPageState();
}

class _MapsPageState extends State<MapsPage> {
  Completer<GoogleMapController> _controller = Completer();

  final Set<Polyline> _polylines = Set();
  final Set<Marker> _markers = Set();

  static final CameraPosition _initialPosition = CameraPosition(
    target: LatLng(12.947437, 77.685345),
    zoom: 15,
  );

  final LatLng _point1 = LatLng(12.947437, 77.681345);
  final LatLng _point2 = LatLng(12.948767, 77.689120);
  final LatLng _point3 = LatLng(12.947216, 77.680614);
  final LatLng _point4 = LatLng(12.948767, 77.609120);

  void prepareMarkers() {
    _markers.add(Marker(
      // This marker id can be anything that uniquely identifies each marker.
      markerId: MarkerId(_point1.toString()),
      //_lastMapPosition is any coordinate which should be your default
      //position when map opens up
      position: _point1,
      icon: BitmapDescriptor.defaultMarker,
    ));

    _markers.add(Marker(
      // This marker id can be anything that uniquely identifies each marker.
      markerId: MarkerId(_point2.toString()),
      //_lastMapPosition is any coordinate which should be your default
      //position when map opens up
      position: _point2,
      icon: BitmapDescriptor.defaultMarker,
    ));

    _markers.add(Marker(
      // This marker id can be anything that uniquely identifies each marker.
      markerId: MarkerId(_point3.toString()),
      //_lastMapPosition is any coordinate which should be your default
      //position when map opens up
      position: _point3,
      icon: BitmapDescriptor.defaultMarker,
    ));

    _markers.add(Marker(
      // This marker id can be anything that uniquely identifies each marker.
      markerId: MarkerId(_point4.toString()),
      //_lastMapPosition is any coordinate which should be your default
      //position when map opens up
      position: _point4,
      icon: BitmapDescriptor.defaultMarker,
    ));
  }

  void prepareCurvedPolylines() {
    _polylines.add(
        Polyline(
          polylineId: PolylineId("line 1"),
          visible: true,
          width: 2,
          //latlng is List<LatLng>
          patterns: [PatternItem.dash(30), PatternItem.gap(10)],
          points: MapsCurvedLines.getPointsOnCurve(_point1, _point2),
          color: Colors.blue,
        )
    );

    _polylines.add(
        Polyline(
          polylineId: PolylineId("line 2"),
          visible: true,
          width: 2,
          //latlng is List<LatLng>
          patterns: [PatternItem.dash(30), PatternItem.gap(10)],
          points: MapsCurvedLines.getPointsOnCurve(_point3, _point4),
          color: Colors.grey,
        )
    );
  }

  @override
  Widget build(BuildContext context) {

    prepareMarkers();
    prepareCurvedPolylines();

    return new Scaffold(
      body: GoogleMap(
        mapType: MapType.normal,
        initialCameraPosition: _initialPosition,
        polylines: _polylines,
        markers: _markers,
        onMapCreated: (GoogleMapController controller) {
          _controller.complete(controller);
        },
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  maps_curved_line: ^0.1.1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:maps_curved_line/maps_curved_line.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
66
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
79
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:maps_curved_line/maps_curved_line.dart, package:maps_curved_line/maps/spherical_utils.dart, package:google_maps_flutter/google_maps_flutter.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:maps_curved_line/maps_curved_line.dart, package:maps_curved_line/maps/spherical_utils.dart, package:google_maps_flutter/google_maps_flutter.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:maps_curved_line/maps_curved_line.dart, package:maps_curved_line/maps/spherical_utils.dart, package:google_maps_flutter/google_maps_flutter.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:maps_curved_line/maps_curved_line.dart, package:maps_curved_line/maps/spherical_utils.dart, package:google_maps_flutter/google_maps_flutter.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [maps_curved_line] that is in a package requiring null.

Health suggestions

Format lib/maps_curved_line.dart.

Run flutter format to format lib/maps_curved_line.dart.

Maintenance issues and suggestions

Homepage URL doesn't exist. (-20 points)

At the time of the analysis the homepage field https://gitlab.com/PraveenKishore/maps_curved_line was unreachable.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
google_maps_flutter ^0.5.25+2 0.5.28+1
Transitive dependencies
collection 1.14.12 1.14.13
flutter_plugin_android_lifecycle 1.0.8
google_maps_flutter_platform_interface 1.0.2
meta 1.1.8
plugin_platform_interface 1.0.2
sky_engine 0.0.99
stream_transform 1.2.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test