Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The getter 'iterator' was called on null. #26

Closed
RageshAntony opened this issue May 20, 2020 · 6 comments
Closed

The getter 'iterator' was called on null. #26

RageshAntony opened this issue May 20, 2020 · 6 comments

Comments

@RageshAntony
Copy link

RageshAntony commented May 20, 2020

I am getting this error when running in Android (Web is fine)

 ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (14948): The following NoSuchMethodError was thrown building WebMap:
I/flutter (14948): The getter 'iterator' was called on null.
I/flutter (14948): Receiver: null
I/flutter (14948): Tried calling: iterator
I/flutter (14948): 
I/flutter (14948): The relevant error-causing widget was:
I/flutter (14948):   WebMap
I/flutter (14948):   file:///home/techrova/Documents/flutter_projects/flutter_complete_guide/lib/selectservice.dart:165:65
I/flutter (14948): 
I/flutter (14948): When the exception was thrown, this was the stack:
I/flutter (14948): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:53:5)
I/flutter (14948): #1      GoogleMapState.initState (package:flutter_google_maps/src/mobile/google_map.state.dart:420:31)
I/flutter (14948): #2      StatefulElement._firstBuild 
..............................

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


GlobalKey<GoogleMapStateBase> _key = GlobalKey<GoogleMapStateBase>();

class WebMap extends StatelessWidget
{
 @override
Widget build(BuildContext context) => GoogleMap(
  key: _key,
  
);

}

I added the API Key in Android Manifest . Even the google_maps_flutter plugin working perfectly

But I am getting error when using this plugin

please help me

I am using latest beta channel of flutter .. Device is Android Pie

@Chojecki
Copy link

You should add at least one marker in new version

@RageshAntony
Copy link
Author

You should add at least one marker in new version

Oohh Ok

I read the docs but can't understand how to add markers ... (what that .Of()??)

Please provide a sample code

Example Markers list (lat,lng)
(9.956719, 78.172637)
(9.908671, 78.149602)

@Chojecki
Copy link

Chojecki commented May 22, 2020

You can just hardcode it like:

GoogleMap( markers: { Marker( GeoCoord(34.0469058, -118.3503948), ), }, ...

I guess it's a bug. My friend spotted that in source code, it's iterating over the all markers, so if there's no any marker, app crash

I did a PR for quick fix

@RageshAntony
Copy link
Author

You can just hardcode it like:

GoogleMap( markers: { Marker( GeoCoord(34.0469058, -118.3503948), ), }, ...

I guess it's a bug. My friend spotted that in source code, it's iterating over the all markers, so if there's no any marker, app crash

I did a PR for quick fix

Yeah working after adding a marker

 Set<Marker> markers = new  Set(); 
   

 @override
Widget build(BuildContext context) {

markers.add(Marker( GeoCoord (9.956719, 78.172637)));
markers.add(Marker( GeoCoord (9.908671, 78.149602)));

   return GoogleMap(
  key: _key,
   markers: markers,
   initialPosition: GeoCoord(9.956719, 78.172637),
);
}

Thanks for your help 

It's better to add this in docs also 

@Chojecki
Copy link

Sorry I'm not maintainer of this package and don't have enough info/time to investigate those kind of errors. Maybe see the example project from repo or ask mainteiners

@march-dev
Copy link
Contributor

Pull request merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants