Open VeerneToor opened 3 years ago
@VeerneToor , Could you please share more details or some code snippet of your implementation?
I had this issue as well, all I had to do was add await _mapControllerCompleter.future
before calling addInfoWindow
.
i have a custom marker and try to call CustomInfo on my marker onTap. But it seems there is no solution for this. i will show my code and the error i have when i tap on a marker.
static Future<Marker> getMarker2(Map<String, dynamic> res, double latitude, double longitude) async {
final Uint8List markerIcon =
await getBytesFromAsset('assets/img/marker.png', 120);
CustomInfoWindowController _customInfoWindowController = CustomInfoWindowController();
double latituded = double.parse(res['latitude']);
double longituded = double.parse(res['longitude']);
final LatLng lat = LatLng(latitude,longitude);
final Marker marker = Marker(
markerId: MarkerId(res['id']),
icon: BitmapDescriptor.fromBytes(markerIcon),
anchor: Offset(0.5, 0.5),
onTap:() {
_customInfoWindowController.addInfoWindow!(
Column(
children: [
Expanded(
child: Container(
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(4),
),
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.account_circle,
color: Colors.white,
size: 30,
),
SizedBox(
width: 8.0,
),
Text(
"I am here",
)
],
),
),
width: double.infinity,
height: double.infinity,
),
),
],
),
lat,
);
},
position: LatLng(
double.parse(res['latitude']), double.parse(res['longitude'])));
CustomInfoWindow(
controller: _customInfoWindowController,
height: 75,
width: 150,
offset: 50,
);
return marker; }
and the error i gave:
E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: Null check operator used on a null value
#1 _GoogleMapState.onMarkerTap (package:google_maps_flutter/src/google_map.dart:367:12)
#2 GoogleMapController._connectStreams.<anonymous closure> (package:google_maps_flutter/src/controller.dart:71:55)
#3 _rootRunUnary (dart:async/zone.dart:1362:47)
#4 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#5 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
#6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#7 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#8 _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:378:25)
#9 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:244:5)
#10 Where.whereType.<anonymous closure> (package:stream_transform/src/where.dart:21:30)
#11 TransformByHandlers.transformByHandlers.<anonymous closure>.<anonymous closure> (package:stream_transform/src/from_handlers.dart:29:50)
#12 _rootRunUnary (dart:async/zone.dart:1362:47)
#13 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#14 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
#15 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#16 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
#17 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
#18 _WhereStream._handleData (dart:async/stream_pipe.dart:195:12)
#19 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
#20 _rootRunUnary (dart:async/zone.dart:1362:47)
#21 _CustomZone.runUnary (dart:async/zone.dart:1265:19)
#22 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1170:7)
#23 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
#24 _DelayedData.perform (dart:async/stream_impl.dart:591:14)
#25 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11)
#26 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:663:7)
#27 _rootRun (dart:async/zone.dart:1346:47)
#28 _CustomZone.run (dart:async/zone.dart:1258:19)
#29 _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
#30 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
#31 _rootRun (dart:async/zone.dart:1354:13)
#32 _CustomZone.run (dart:async/zone.dart:1258:19)
#33 _CustomZone.runGuarded (dart:async/zone.dart:1162:7)
#34 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1202:23)
#35 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
#36 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
Hi @Mad-Bones, there is some issue with your code. You are trying to create CustomInfoWindowController and CustomInfoWindow for every marker in "getMarker2". As per the implementation there should be one CustomInfoWindowController and one CustomInfoWindow for GoogleMap instance. Please go though the example one more time and let me know if there is any problem.
I had this issue as well, all I had to do was add
await _mapControllerCompleter.future
before callingaddInfoWindow
.
@francoguilherme Thanks for providing the fix. Will close this issue after adding this condition in the package.
I had this issue as well, all I had to do was add
await _mapControllerCompleter.future
before callingaddInfoWindow
.
What exactly is _mapControllerCompleter? I assumed it was this 'Completer
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Null check operator used on a null value
E/flutter (25810): #0 MapSampleState.infoWin (package:d_monitor_app/pages/MapScreen.dart:301:45)
E/flutter (25810):
you must create your CustomInfoWindow near your GoogleMap instance within a stack for example. take a look at the example.
`lib/screens/avl/avl_flota.dart:142:56: Error: Can't use an expression of type 'dynamic Function(Widget, LatLng)?' as a function because it's potentially null.
I have the same error.... someone fix this error on flutter 3.10?
When trying to show an InfoWindow I get the following error:
Unhandled Exception: NoSuchMethodError: The method 'call' was called on null
, It is highlighted that the update of the Map controller is done