A Flutter package which can be used to make polylines(route) from a source to a destination, and also handle a driver's realtime location (if any) on the map.

Overview

GoogleMapsWidget For Flutter

pub package likes popularity pub points

A widget for flutter developers to easily integrate google maps in their apps. It can be used to make polylines from a source to a destination, and also handle a driver's realtime location (if any) on the map.

Features

  • Make polylines (route) between two locations by providing the latitude and longitude for both the locations.
  • The route is customizable in terms of color and width.
  • The plugin also offers realtime location tracking for a driver(if any) and shows a marker on the map which updates everytimes the driver's location changes.
  • All the markers are customizable.
  • onTap callbacks are implemented for all the markers and their info windows to easily handle user interaction.
  • Almost all the parameters defined in google_maps_flutter for the GoogleMap widget can be passed as arguments to the widget.

Screenshots

      

Getting Started

  • Get an API key at https://cloud.google.com/maps-platform/.

  • Enable Google Map SDK for each platform.

    • Go to Google Developers Console.
    • Choose the project that you want to enable Google Maps on.
    • Select the navigation menu and then select "Google Maps".
    • Select "APIs" under the Google Maps menu.
    • To enable Google Maps for Android, select "Maps SDK for Android" in the "Additional APIs" section, then select "ENABLE".
    • To enable Google Maps for iOS, select "Maps SDK for iOS" in the "Additional APIs" section, then select "ENABLE".
    • To enable Directions API, select "Directions API" in the "Additional APIs" section, then select "ENABLE".
    • Make sure the APIs you enabled are under the "Enabled APIs" section.

For more details, see Getting started with Google Maps Platform.

Android

Specify your API key in the application manifest android/app/src/main/AndroidManifest.xml:

<manifest ...
  <application ...
    <meta-data android:name="com.google.android.geo.API_KEY"
               android:value="YOUR KEY HERE"/>

iOS

Specify your API key in the application delegate ios/Runner/AppDelegate.m:

#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#import "GoogleMaps/GoogleMaps.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [GMSServices provideAPIKey:@"YOUR KEY HERE"];
  [GeneratedPluginRegistrant registerWithRegistry:self];
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end

Or in your swift code, specify your API key in the application delegate ios/Runner/AppDelegate.swift:

import UIKit
import Flutter
import GoogleMaps

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GMSServices.provideAPIKey("YOUR KEY HERE")
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

Web

Modify web/index.html

Get an API Key for Google Maps JavaScript API. Get started here. Modify the <head> tag of your web/index.html to load the Google Maps JavaScript API, like so:

<head>

  <!-- // Other stuff -->

  <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_HERE"></script>
</head>

Usage

To use this plugin, add google_maps_widget as a dependency in your pubspec.yaml file.

  dependencies:
    flutter:
      sdk: flutter
    google_maps_widget:

First and foremost, import the widget.

import 'package:google_maps_widget/google_maps_widget.dart';

You can now add a GoogleMapsWidget widget to your widget tree and pass all the required parameters to get started. This widget will create a route between the source and the destination LatLng's provided.

GoogleMapsWidget(
    apiKey: "YOUR KEY HERE",
    sourceLatLng: LatLng(40.484000837597925, -3.369978368282318),
    destinationLatLng: LatLng(40.48017307700204, -3.3618026599287987),
),

Sample Usage

import 'package:flutter/material.dart';
import 'package:google_maps_widget/google_maps_widget.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: SafeArea(
        child: Scaffold(
          body: GoogleMapsWidget(
            apiKey: "YOUR KEY HERE",
            sourceLatLng: LatLng(40.484000837597925, -3.369978368282318),
            destinationLatLng: LatLng(40.48017307700204, -3.3618026599287987),

            ///////////////////////////////////////////////////////
            //////////////    OPTIONAL PARAMETERS    //////////////
            ///////////////////////////////////////////////////////

            routeWidth: 2,
            sourceMarkerIconInfo: MarkerIconInfo(
              assetPath: "assets/images/house-marker-icon.png",
            ),
            destinationMarkerIconInfo: MarkerIconInfo(
              assetPath: "assets/images/restaurant-marker-icon.png",
            ),
            driverMarkerIconInfo: MarkerIconInfo(
              assetPath: "assets/images/driver-marker-icon.png",
              assetMarkerSize: Size.square(125),
            ),
            // mock stream
            driverCoordinatesStream: Stream.periodic(
              Duration(milliseconds: 500),
              (i) => LatLng(
                40.47747872288886 + i / 10000,
                -3.368043154478073 - i / 10000,
              ),
            ),
            sourceName: "This is source name",
            driverName: "Alex",
            onTapDriverMarker: (currentLocation) {
              print("Driver is currently at $currentLocation");
            },
            totalTimeCallback: (time) => print(time),
            totalDistanceCallback: (distance) => print(distance),

            /// and a lot more...
          ),
        ),
      ),
    );
  }
}

See the example directory for a complete sample app.

Created & Maintained By Rithik Bhandari

Comments
  • Platform Exception

    Platform Exception

    Hi, FIrst, really nice library. I have an error wile trying to paint a polyline route between 2 points.

    [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(error, Error using newLatLngBounds(LatLngBounds, int): Map size can't be 0. Most likely, layout has not yet occured for the map view.  Either wait until layout has occurred or use newLatLngBounds(LatLngBounds, int, int, int) which allows you to specify the map's dimensions., null, com.google.maps.api.android.lib6.common.apiexception.c: Error using newLatLngBounds(LatLngBounds, int): Map size can't be 0. Most likely, layout has not yet occured for the map view.  Either wait until layout has occurred or use newLatLngBounds(LatLngBounds, int, int, int) which allows you to specify the map's dimensions.
    

    I have a list of maps to show different trips.

    My parameters are:

                           sourceLatLng: LatLng(originLatitude!, originLongitude!),
                            destinationLatLng:
                                LatLng(destinationLatitude!, destinationLongitude!),
                            routeColor: AppColors.primaryColor,
                            scrollGesturesEnabled: true,
                            rotateGesturesEnabled: true,
                            routeWidth: 1,
                            zoomGesturesEnabled: true,
                            showPolyline: true,
                            zoomControlsEnabled: true,
    

    Runnig last version of google maps flutter and flutter 3.2

    opened by arcas0803 8
  • Dynamic polylines

    Dynamic polylines

    Hello, I want the polylines to be generated on the map dynamically based on drivers position and a fixed destination. So basically as driver moves closer to destination previous lines disappear as it has a new source location I am getting stream of driver latitude and longitude from the api. How do I set a dynamic source location or what is the best possible way to handle this? Thanks

    opened by ShivamMattoo33 7
  • Regarding driverCoordinatesStream

    Regarding driverCoordinatesStream

    Hello, I have an api call that returns me back latitude and longitude. I want to make that call every second and then pass it in driverCoordinatesStream and make the vehicle move Can you help me how to do that? I am using bloc but if you are not familiar with it you can just help with directly call as well

        
      driverCoordinatesStream: Stream.periodic(
                                Duration(seconds: 1),
                                (_) {
                                  double? lat;
                                  double? long;
    // Making API call 
                                  BlocProvider.of<RsaTrackerCubit>(context).getTowTruckTrackingLocationInfo();
    // if successful update latitude longitude
                                  if (state is RsaTowTruckLocationSuccessfullState && lat != null && long != null) {
                                    lat = state.towTruckTrackingResponse?.job?.partner?.vehicle?.location?.lat?.toDouble();
                                    long = state.towTruckTrackingResponse?.job?.partner?.vehicle?.location?.long?.toDouble();
    // if unsuccessful use the last successful value
                                  } else {
                                    lat = lat;
                                    long = long;
                                  }
    
                                  return LatLng(
                                    lat ?? 35.957819,
                                    long ?? -81.998999,
                                  );
                                },
                              ),
    
    
    

    Please let me know if its possible or not or if any other alternatives

    opened by ShivamMattoo33 7
  • Why another `apiKey` inside the flutter app?

    Why another `apiKey` inside the flutter app?

    Hello,

    thank for this awesome plugin. It simplified my workflow and made me gain some time. Now I just don't understand why I need to add a key inside the dart code, when I already added it inside the android manifest and iOS Runner App, and also the web?

    opened by stephane-segning 3
  • Does this Widget work for web?

    Does this Widget work for web?

    When I try to compile for web, I simply get "TargetPlatform is not yet supported" in place of the map when I visit the web page.

    I have added the link with my API key inside web/index.html as it says in the README.

    On pub.dev it says that web is supported by this plugin. What's the status?

    opened by EriKWDev 2
  • Ability to Rotate car to Path Direction

    Ability to Rotate car to Path Direction

    Hello, I am trying to implement a tracker service and I want the car marker to point towards the road it headed to. Upon doing some research I would want the rotate parameter in the Marker for at least driverMarkerIconInfo unless you recommend any other way? Thanks

    enhancement 
    opened by ShivamMattoo33 2
  • error when closing or exiting the map

    error when closing or exiting the map

    Hello, how are you? every time you try to exit or close the map it gives this error

    `I/flutter (25140): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ I/flutter (25140): The following assertion was thrown while finalizing the widget tree: I/flutter (25140): 'package:flutter/src/widgets/framework.dart': Failed assertion: line 4276 pos 12: '_lifecycleState I/flutter (25140): != _ElementLifecycle.defunct': is not true. I/flutter (25140): I/flutter (25140): Either the assertion indicates an error in the framework itself, or we should provide substantially I/flutter (25140): more information in this error message to help you determine and fix the underlying cause. I/flutter (25140): In either case, please report this assertion by filing a bug on GitHub: I/flutter (25140): https://github.com/flutter/flutter/issues/new?template=2_bug.md I/flutter (25140): I/flutter (25140): When the exception was thrown, this was the stack: I/flutter (25140): #2 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:4276:12) I/flutter (25140): #3 State.setState (package:flutter/src/widgets/framework.dart:1108:15) I/flutter (25140): #4 MapsService.clear (package:google_maps_widget/src/services/maps_service.dart:365:14) I/flutter (25140): #5 _GoogleMapsWidgetState.dispose (package:google_maps_widget/src/main_widget.dart:387:18) I/flutter (25140): #6 StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4895:11) I/flutter (25140): #7 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1883:13) I/flutter (25140): #8 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #9 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6297:16) I/flutter (25140): #10 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #11 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #12 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #13 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #14 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #15 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #16 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #17 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #18 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #19 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #20 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #21 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6297:16) I/flutter (25140): #22 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #23 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #24 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #25 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #26 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #27 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #28 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #29 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #30 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #31 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #32 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #33 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) I/flutter (25140): #34 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #35 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #36 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #37 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #38 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #39 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) I/flutter (25140): #40 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #41 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #42 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #43 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #44 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #45 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #46 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #47 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #48 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #49 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #50 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #51 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #52 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #53 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #54 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #55 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #56 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #57 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #58 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #59 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #60 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #61 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #62 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #63 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #64 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #65 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #66 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #67 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #68 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #69 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) I/flutter (25140): #70 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #71 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #72 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #73 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #74 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #75 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) I/flutter (25140): #76 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #77 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #78 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) I/flutter (25140): #79 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #80 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #81 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #82 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #83 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #84 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) I/flutter (25140): #85 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #86 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #87 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) I/flutter (25140): #88 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #89 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #90 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #91 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #92 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #93 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #94 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #95 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #96 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #97 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #98 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #99 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) I/flutter (25140): #100 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #101 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #102 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) I/flutter (25140): #103 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #104 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #105 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #106 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #107 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #108 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) I/flutter (25140): #109 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #110 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #111 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #112 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #113 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #114 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #115 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #116 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #117 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #118 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #119 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #120 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #121 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #122 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #123 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14)

    ======== Exception caught by widgets library ======================================================= The following assertion was thrown while finalizing the widget tree: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 4276 pos 12: '_lifecycleState != _ElementLifecycle.defunct': is not true.

    Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause. In either case, please report this assertion by filing a bug on GitHub: https://github.com/flutter/flutter/issues/new?template=2_bug.md

    When the exception was thrown, this was the stack: #2 Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:4276:12) #3 State.setState (package:flutter/src/widgets/framework.dart:1108:15) #4 MapsService.clear (package:google_maps_widget/src/services/maps_service.dart:365:14) #5 _GoogleMapsWidgetState.dispose (package:google_maps_widget/src/main_widget.dart:387:18) #6 StatefulElement.unmount (package:flutter/src/widgets/framework.dart:4895:11) #7 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1883:13) #8 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #9 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6297:16) #10 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #11 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #12 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #13 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #14 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #15 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #16 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #17 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #18 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #19 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #20 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #21 MultiChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6297:16) #22 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #23 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #24 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #25 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #26 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #27 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #28 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #29 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #30 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #31 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #32 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #33 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) #34 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #35 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #36 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #37 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #38 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #39 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) #40 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #41 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #42 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #43 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #44 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #45 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #46 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #47 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #48 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #49 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #50 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #51 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #52 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #53 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #54 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #55 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #56 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #57 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #58 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #59 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #60 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #61 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #62 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #63 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #64 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #65 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #66 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #67 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #68 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #69 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) #70 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #71 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #72 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #73 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #74 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #75 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) #76 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #77 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #78 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) #79 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #80 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #81 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #82 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #83 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #84 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) #85 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #86 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #87 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) #88 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #89 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #90 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #91 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #92 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #93 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #94 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #95 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #96 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #97 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #98 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #99 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) #100 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #101 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #102 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) #103 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #104 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #105 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #106 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #107 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #108 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) #109 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #110 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #111 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #112 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #113 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #114 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #115 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #116 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #117 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #118 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #119 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #120 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #121 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #122 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #123 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #124 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #125 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #126 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #127 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #128 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #129 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) #130 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #131 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #132 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #133 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #134 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #135 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #136 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #137 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #138 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #139 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #140 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #141 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #142 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #143 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #144 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #145 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #146 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #147 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) #148 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #149 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #150 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #151 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #152 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #153 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #154 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #155 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) #156 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) #157 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) #158 ListIterable.forEach (dart:_internal/iterable.dart:39:13) #159 _InactiveElements._unmountAll (package:flutter/src/widgets/framework.dart:1892:25) #160 BuildOwner.finalizeTree. (package:flutter/src/widgets/framework.dart:2879:27) #161 BuildOwner.lockState (package:flutter/src/widgets/framework.dart:2510:15) #162 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:2878:7) #163 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:884:19) #164 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:319:5) #165 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1143:15) #166 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1080:9) #167 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:996:5) #171 _invoke (dart:ui/hooks.dart:166:10) #172 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:270:5) #173 _drawFrame (dart:ui/hooks.dart:129:31) (elided 5 frames from class _AssertionError and dart:async)

    I/flutter (25140): #124 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #125 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #126 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #127 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #128 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #129 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) I/flutter (25140): #130 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #131 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #132 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #133 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #134 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #135 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #136 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #137 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #138 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #139 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #140 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #141 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #142 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #143 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #144 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #145 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #146 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #147 SingleChildRenderObjectElement.visitChildren (package:flutter/src/widgets/framework.dart:6182:14) I/flutter (25140): #148 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #149 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #150 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #151 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #152 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #153 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #154 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #155 _InactiveElements._unmount. (package:flutter/src/widgets/framework.dart:1881:7) I/flutter (25140): #156 ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:4719:14) I/flutter (25140): #157 _InactiveElements._unmount (package:flutter/src/widgets/framework.dart:1879:13) I/flutter (25140): #158 ListIterable.forEach (dart:_internal/iterable.dart:39:13) I/flutter (25140): #159 _InactiveElements._unmountAll (package:flutter/src/widgets/framework.dart:1892:25) I/flutter (25140): #160 BuildOwner.finalizeTree. (package:flutter/src/widgets/framework.dart:2879:27) I/flutter (25140): #161 BuildOwner.lockState (package:flutter/src/widgets/framework.dart:2510:15) I/flutter (25140): #162 BuildOwner.finalizeTree (package:flutter/src/widgets/framework.dart:2878:7) I/flutter (25140): #163 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:884:19) I/flutter (25140): #164 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:319:5) I/flutter (25140): #165 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1143:15) I/flutter (25140): #166 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1080:9) I/flutter (25140): #167 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:996:5) I/flutter (25140): #171 _invoke (dart:ui/hooks.dart:166:10) I/flutter (25140): #172 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:270:5) I/flutter (25140): #173 _drawFrame (dart:ui/hooks.dart:129:31) I/flutter (25140): (elided 5 frames from class _AssertionError and dart:async) I/flutter (25140): ════════════════════════════════════════════════════════════════════════════════════════════════════ `

    opened by GrandeSamarone 2
Releases(v1.0.5+1)
  • v1.0.5+1(Oct 25, 2022)

  • v1.0.5(Oct 25, 2022)

    • BREAKING: MarkerIconInfo inputs are now non-nullable
    • BREAKING: Added properties onTapMarker, onTapInfoWindow, infoWindowTitle and isVisible to MarkerIconInfo, and removed corresponding params for source, destination, driver from GoogleMapsWidget
    • Changed internal implementation of the widget
    • Added layoutDirection property
    • Added onPolylineUpdate callback
    • Exposed state class to allow updating source/destination lat lng, or interacting with google maps con directly
    • Updated a dependency to the latest release
    • Updated example app
    • Updated README.md
    Source code(tar.gz)
    Source code(zip)
  • v1.0.4(Jun 15, 2022)

    • Added updatePolylinesOnDriverLocUpdate to update directions based on current driver location
    • Updated dependencies
    • Updated example app
    • Updated README.md
    Source code(tar.gz)
    Source code(zip)
  • v1.0.3(Jun 14, 2022)

  • v1.0.2(Jun 7, 2022)

  • v1.0.1(Jan 26, 2022)

    GoogleMapsWidget For Flutter

    pub package likes popularity pub points

    A widget for flutter developers to easily integrate google maps in their apps. It can be used to make polylines from a source to a destination, and also handle a driver's realtime location (if any) on the map.

    Features

    • Make polylines (route) between two locations by providing the latitude and longitude for both the locations.
    • The route is customizable in terms of color and width.
    • The plugin also offers realtime location tracking for a driver(if any) and shows a marker on the map which updates everytimes the driver's location changes.
    • All the markers are customizable.
    • onTap callbacks are implemented for all the markers and their info windows to easily handle user interaction.
    • Almost all the parameters defined in google_maps_flutter for the GoogleMap widget can be passed as arguments to the widget.

    Screenshots

          

    Getting Started

    • Get an API key at https://cloud.google.com/maps-platform/.

    • Enable Google Map SDK for each platform.

      • Go to Google Developers Console.
      • Choose the project that you want to enable Google Maps on.
      • Select the navigation menu and then select "Google Maps".
      • Select "APIs" under the Google Maps menu.
      • To enable Google Maps for Android, select "Maps SDK for Android" in the "Additional APIs" section, then select "ENABLE".
      • To enable Google Maps for iOS, select "Maps SDK for iOS" in the "Additional APIs" section, then select "ENABLE".
      • To enable Directions API, select "Directions API" in the "Additional APIs" section, then select "ENABLE".
      • Make sure the APIs you enabled are under the "Enabled APIs" section.

    For more details, see Getting started with Google Maps Platform.

    Android

    Specify your API key in the application manifest android/app/src/main/AndroidManifest.xml:

    <manifest ...
      <application ...
        <meta-data android:name="com.google.android.geo.API_KEY"
                   android:value="YOUR KEY HERE"/>
    

    iOS

    Specify your API key in the application delegate ios/Runner/AppDelegate.m:

    #include "AppDelegate.h"
    #include "GeneratedPluginRegistrant.h"
    #import "GoogleMaps/GoogleMaps.h"
    
    @implementation AppDelegate
    
    - (BOOL)application:(UIApplication *)application
        didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      [GMSServices provideAPIKey:@"YOUR KEY HERE"];
      [GeneratedPluginRegistrant registerWithRegistry:self];
      return [super application:application didFinishLaunchingWithOptions:launchOptions];
    }
    @end
    

    Or in your swift code, specify your API key in the application delegate ios/Runner/AppDelegate.swift:

    import UIKit
    import Flutter
    import GoogleMaps
    
    @UIApplicationMain
    @objc class AppDelegate: FlutterAppDelegate {
      override func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
      ) -> Bool {
        GMSServices.provideAPIKey("YOUR KEY HERE")
        GeneratedPluginRegistrant.register(with: self)
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
      }
    }
    

    Web

    Modify web/index.html

    Get an API Key for Google Maps JavaScript API. Get started here. Modify the <head> tag of your web/index.html to load the Google Maps JavaScript API, like so:

    <head>
    
      <!-- // Other stuff -->
    
      <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_KEY_HERE"></script>
    </head>
    

    Usage

    To use this plugin, add google_maps_widget as a dependency in your pubspec.yaml file.

      dependencies:
        flutter:
          sdk: flutter
        google_maps_widget:
    

    First and foremost, import the widget.

    import 'package:google_maps_widget/google_maps_widget.dart';
    

    You can now add a GoogleMapsWidget widget to your widget tree and pass all the required parameters to get started. This widget will create a route between the source and the destination LatLng's provided.

    GoogleMapsWidget(
        apiKey: "YOUR KEY HERE",
        sourceLatLng: LatLng(40.484000837597925, -3.369978368282318),
        destinationLatLng: LatLng(40.48017307700204, -3.3618026599287987),
    ),
    

    Sample Usage

    import 'package:flutter/material.dart';
    import 'package:google_maps_widget/google_maps_widget.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: SafeArea(
            child: Scaffold(
              body: GoogleMapsWidget(
                apiKey: "YOUR KEY HERE",
                sourceLatLng: LatLng(40.484000837597925, -3.369978368282318),
                destinationLatLng: LatLng(40.48017307700204, -3.3618026599287987),
    
                ///////////////////////////////////////////////////////
                //////////////    OPTIONAL PARAMETERS    //////////////
                ///////////////////////////////////////////////////////
    
                routeWidth: 2,
                sourceMarkerIconInfo: MarkerIconInfo(
                  assetPath: "assets/images/house-marker-icon.png",
                ),
                destinationMarkerIconInfo: MarkerIconInfo(
                  assetPath: "assets/images/restaurant-marker-icon.png",
                ),
                driverMarkerIconInfo: MarkerIconInfo(
                  assetPath: "assets/images/driver-marker-icon.png",
                  assetMarkerSize: Size.square(125),
                ),
                // mock stream
                driverCoordinatesStream: Stream.periodic(
                  Duration(milliseconds: 500),
                  (i) => LatLng(
                    40.47747872288886 + i / 10000,
                    -3.368043154478073 - i / 10000,
                  ),
                ),
                sourceName: "This is source name",
                driverName: "Alex",
                onTapDriverMarker: (currentLocation) {
                  print("Driver is currently at $currentLocation");
                },
                totalTimeCallback: (time) => print(time),
                totalDistanceCallback: (distance) => print(distance),
    
                /// and a lot more...
              ),
            ),
          ),
        );
      }
    }
    
    

    See the example directory for a complete sample app.

    Created & Maintained By Rithik Bhandari

    Source code(tar.gz)
    Source code(zip)
mezza 0 Nov 24, 2021
Building a simple Flutter app for practicing and understanding the GetX State Management and Route Management.

GetX State Management Demo with full understanding of State Management (with GetBuiler, GetX, Obx), Route Management and SnackBar.

TAD 4 Oct 2, 2022
Tahseen Quraishi 20 Dec 3, 2022
An example showing how to handle common scrolling gesture conflicts in Flutter.

scroll_master An example showing how to handle common scrolling gesture conflicts in Flutter.

null 11 Nov 11, 2022
A simple, interactive and customizable on-tap bounce animation that can be wrapped on any widgets that you like.

A simple, interactive and customizable on-tap bounce animation that can be wrapped on any widgets that you like.

null 16 Nov 2, 2022
SeeFood is a Flutter app which tells you whether photograph contains any food items or not.

See Food ?? ?? See Food is a Flutter app which tells you whether photograph contains any food items or not. This app is highly inspired by and an atte

Tirth 23 Oct 8, 2022
Flutter Chat Socket - using Flutter for develop a realtime chat app

Flutter Chat Socket - using Flutter for develop a realtime chat app

Rois Khoiron 4 Dec 7, 2022
Cryptocurrency App with MVP Design Pattern to track all the coins data in realtime for android & iOS . Written in dart using Flutter SDK.

Flutter CryptoCurrency App (MVP) Cryptocurrency App with MVP design pattern to track all the coins data in realtime for android & iOS . Written in dar

Pawan Kumar 287 Dec 30, 2022
Realtime chat application interface using Socket.IO for Flutter GDSC event

flutter_socket_chatapp Simplet multi user chat app using Socket.IO and API calls Getting Started This project is a starting point for a Flutter applic

Soorya Senthil Rajan 1 Jun 15, 2022
Spyxpo Web to App Builder - a tool which is used to convert a website into an app for iOS, Android, Windows, macOS and Linux.

Spyxpo Web to App Builder Convert any website into an iOS/Android app. This is a preview build for testing purposes major update coming soon. Supporte

Spyxpo 4 Aug 24, 2022
An app to get you the latest and the trending news based on your location.

An app to get you the latest and the trending news based on your location.

Ayush Shekhar 19 Nov 11, 2022
Flutter social button - A flutter package to create social media login buttons easily to any flutter app

Flutter Social Button is a flutter package to create social media login buttons easily to any flutter app.

Alok Dubey 10 Dec 5, 2022
Flutterbase taxi - A large variety of apps depend on map services.

Flutterbase taxi A large variety of apps depend on map services. The purpose of this project was to test Google Map Services in connection with Flutte

Yakiv Galkin 110 Dec 29, 2022
Flutter Chat Application with location integration using GetStream

Chat Location Generated by the Very Good CLI ?? A chat application built with Flutter using the Stream Chat SDK. Check out the full tutorial. Getting

Very Good Ventures 77 Jan 4, 2023
Sorting of locations ref. nearest location.

Locations Sort locations with nearest distance How it works? Get user's current location Compare with other destinations Sort according the nearest Th

Frantic 9 Dec 22, 2022
A Dart-written Android app to make taking notes, tasks and events easy and straight forward

A Dart-written Android app to make taking notes, tasks and events easy and straight forward

n0pe 3 Nov 15, 2022
11t is an iOS and Android app for connecting to Mastodon, written in Flutter. 11t lets you use any Mastodon instance.

README 11t is an iOS and Android app for connecting to Mastodon, written in Flutter. I connect to Mastodon on mastodon.social, but everyone can start

Jeroen Smeets 88 Dec 23, 2022
a simple Quran app made with flutter without any images or pdf

forqan A simple Quran app made with flutter without any images or pdf . screenshot Support If you like what we do, and would want to help us continue

null 15 Oct 22, 2022
A thank you page made in flutter for successful payment status in any application.

thanku A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this i

Dr. Usman 2 Jan 3, 2023