Pratishtha S
Pratishtha S

Reputation: 91

Unhandled Exception: Bad state: No element in case of using Maps

I am using Geocoder2 in my Flutter code and when my app runs and I tap on different locations, I get this exception. My code is:

 LatLng point=LatLng(40, -1);
 GeoData? location;
 FlutterMap(
            options: MapOptions(
            onTap: (p, point) async {
              location = await Geocoder2.getDataFromCoordinates(
                  latitude: point.latitude, longitude: point.longitude, googleMapApiKey: 'GOOGLE API KEY');
            print("${location?.country}");
              setState((){
                point=p as LatLng;
              });
            },
            center: LatLng(40, -1),
            zoom: 15.0
          ),
          layers: [
            TileLayerOptions(
              urlTemplate: "URL",
              subdomains: ['a','b','c'],
            ),
            MarkerLayerOptions(markers: [
              Marker(
                  width:200.0,
                  height:200.0,
                  point: point, builder: (ctx)=> Icon(
                Icons.location_on, color: Colors.red,
                size:40.0,
              )),
            ],
            ),

          ],
          ),
 Card(child: Padding(
                  padding: EdgeInsets.all(16.0),
    // child: Text("new location",
    child: Text("${location?.country}, ${location?.city}, ${location?.state}",
                  style: TextStyle(fontWeight: FontWeight.bold),),
                ),)
D/ViewRootImpl[MainActivity]( 4093):  debugCancelDraw some OnPreDrawListener onPreDraw return false,cancelDraw=true,count=50,android.view.ViewRootImpl@d8baac5
W/System  ( 4093): Ignoring header X-Firebase-Locale because its value was null.
D/hw-ProcessState( 4093): Binder ioctl to enable oneway spam detection failed: Invalid argument
D/SurfaceComposerClient( 4093): VRR [FRTC] client handle [bufferId:18446744073709551615 framenumber:0] [ffffffff, ffffffff]
E/OpenGLRenderer( 4093): fbcNotifyFrameComplete error: undefined symbol: fbcNotifyFrameComplete
E/OpenGLRenderer( 4093): fbcNotifyNoRender error: undefined symbol: fbcNotifyNoRender
D/ViewRootImpl[MainActivity]( 4093):  debugCancelDraw  cancelDraw=false,count = 200,android.view.ViewRootImpl@d8baac5
D/SurfaceComposerClient( 4093): VRR [FRTC] client handle [bufferId:18446744073709551615 framenumber:0] [ffffffff, ffffffff]
E/BLASTBufferQueue( 4093): [SurfaceView[com.example.mfieldtrip/com.example.mfieldtrip.MainActivity]#1](f:0,a:2) isEGL=1, mPendingRelease.size()=1, mMaxAcquiredBuffers=4, currentMaxAcquiredBufferCount=2
E/BLASTBufferQueue( 4093): [SurfaceView[com.example.mfieldtrip/com.example.mfieldtrip.MainActivity]#1](f:0,a:3) isEGL=1, mPendingRelease.size()=2, mMaxAcquiredBuffers=4, currentMaxAcquiredBufferCount=2
V/AutofillManager( 4093): requestHideFillUi(null): anchor = null
V/AutofillManager( 4093): requestHideFillUi(null): anchor = null
E/flutter ( 4093): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: Bad state: No element
E/flutter ( 4093): #0      List.first (dart:core-patch/growable_array.dart:343:5)
E/flutter ( 4093): #1      Geocoder2.getDataFromCoordinates (package:geocoder2/src/geocoder2.dart:24:44)
E/flutter ( 4093): <asynchronous suspension>
E/flutter ( 4093): #2      _HomePageState.build.<anonymous closure> (package:mfieldtrip/Home.dart:124:26)
E/flutter ( 4093): <asynchronous suspension>
E/flutter ( 4093): 
E/Parcel  ( 4093): Reading a NULL string not supported here.
I/BufferQueueProducer( 4093): [SurfaceView[com.example.mfieldtrip/com.example.mfieldtrip.MainActivity]#1(BLAST Consumer)1](id:ffd00000001,api:1,p:4093,c:4093) disconnect: api 1
E/BLASTBufferQueue( 4093): BLASTBufferItemConsumer::onDisconnect()
I/BufferQueueProducer( 4093): [SurfaceView[com.example.mfieldtrip/com.example.mfieldtrip.MainActivity]#1(BLAST Consumer)1](id:ffd00000001,api:0,p:-1,c:4093) disconnect: api -1
I/BufferQueueProducer( 4093): [ViewRootImpl[MainActivity]#0(BLAST Consumer)0](id:ffd00000000,api:1,p:4093,c:4093) disconnect: api 1
E/BLASTBufferQueue( 4093): BLASTBufferItemConsumer::onDisconnect()
I/BLASTBufferQueue( 4093): [ViewRootImpl[MainActivity]#0] destructor()
I/BufferQueueConsumer( 4093): [ViewRootImpl[MainActivity]#0(BLAST Consumer)0](id:ffd00000000,api:0,p:-1,c:4093) disconnect
I/libPerfCtl( 4093): fbcNotifySbeRescue ret=-1
I/libPerfCtl( 4093): fbcNotifySbeRescue ret=-1
I/BLASTBufferQueue( 4093): releaseBufferCallbackThunk bufferId:17579301142529 framenumber:1 blastBufferQueue is dead
I/libPerfCtl( 4093): fbcNotifySbeRescue ret=-1
I/libPerfCtl( 4093): fbcNotifySbeRescue ret=-1

This is my log when I run the app(most of it is same).Also, for google map ALI, I did -> go to credentials and then API and used that API directly in geocoder function. That's right? Please, if someone can help!

Upvotes: 0

Views: 1331

Answers (0)

Related Questions