当视图加载两次时,Google Map使Flutter崩溃

时间:2019-06-25 12:03:27

标签: flutter google-maps-flutter

我将Firestore用作数据库,并使用StreamBuilder路由来检查isLoggedIn。首次登录时,Google Map工作正常,但是再次登录时,崩溃并显示以下错误:

D/libEGL  (11553): eglInitialize: enter
D/libEGL  (11553): eglInitialize: exit(res=1)
W/com.flutter.geolocation(11553): type=1400 audit(0.0:18911): avc: denied { search } for comm=474C5468726561642037323135 name="ctx" dev="debugfs" ino=15090 scontext=u:r:untrusted_app_27:s0:c512,c768 tcontext=u:object_r:qti_debugfs:s0 tclass=dir permissive=0
D/AndroidRuntime(11553): Shutting down VM
E/AndroidRuntime(11553): FATAL EXCEPTION: main
E/AndroidRuntime(11553): Process: com.flutter.geolocation, PID: 11553
E/AndroidRuntime(11553): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.view.Display.getDisplayId()' on a null object reference
E/AndroidRuntime(11553):        at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:4260)
E/AndroidRuntime(11553):        at android.os.Handler.dispatchMessage(Handler.java:106)
E/AndroidRuntime(11553):        at android.os.Looper.loop(Looper.java:201)
E/AndroidRuntime(11553):        at android.app.ActivityThread.main(ActivityThread.java:6806)
E/AndroidRuntime(11553):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(11553):        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
E/AndroidRuntime(11553):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
E/MQSEventManagerDelegate(11553): failed to get MQSService.
W/System  (11553): A resource failed to call release.
I/Process (11553): Sending signal. PID: 11553 SIG: 9
Lost connection to device.
Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        title: Text("GeoLocation"),
      ),
      drawer: DrawerWidget(name: widget.name, userID: widget.userID,),
      body: Stack(
        children: <Widget>[
          GoogleMap(
            initialCameraPosition: CameraPosition(
              target: LatLng(26.2389, 73.0243),
              zoom: 12
            ),
            rotateGesturesEnabled: true,
            compassEnabled: true,
            onMapCreated: _onMapCreated,
            myLocationEnabled: true,
            myLocationButtonEnabled: false,
            mapType: MapType.normal,
            polylines: Set<Polyline>.of(_mapPolylines.values),
          ),
          Positioned(
            bottom: 50,
            right: 20,
            child: RawMaterialButton(
              child: Icon(Icons.gps_fixed, size: 30.0),
              fillColor: white,
              shape: new CircleBorder(),
              onPressed: _animateToUser,
              padding: EdgeInsets.all(8.0),
            ),
          ),
          StreamBuilder(
            stream: Firestore.instance.collection(widget.institute.toString()).document(widget.bus.toString()).collection("Driver").snapshots(),
            builder: (context, snap) {
              if(snap.hasData) {
                List<DocumentSnapshot> snapshot = snap.data.documents;
                if(snapshot[0]['session'] == 1)
                {
                  return Container(
                    height: 50,
                    width: double.infinity,
                    child: Text("Online", textAlign: TextAlign.center,),
                    color: white,
                  );
                } else {
                  return Container(
                    height: 50,
                    width: double.infinity,
                    child: Text("Offline", textAlign: TextAlign.center,),
                    color: white,
                  );
                }
              } else {
                return Container(
                    child: Text("Error Data"),
                );
              }
            },
          )
        ],
      ),
    );
  }


当我删除Google Maps Widget时,它完全可以正常工作。 我应该使用其他地图插件/软件包吗?

0 个答案:

没有答案