1

Bom, vamos lá... Estou desenvolvento uma aplicação utilizando flutter (sou novato com a lingua dart), então preciso que minha aplicação atualize os markers do maps periodicamente junto com o WebSocket, porem quando o mesmo atualiza meu maps para de funcionar, deixando assim a tela toda branca...

@override

void initState() {
    super.initState();
    checkUserLogged();
    _getAddrs();
    wsConnect();
  }

  @override
  void dispose() {
    channel.sink.close();
    super.dispose();
  }

  wsConnect() async {
    channel = await IOWebSocketChannel.connect('ws://31.220.54.205:3002');
    channel.stream.listen((message) {
      channel.sink.add(message);
    });
  }




StreamBuilder(
                stream: channel.stream,
                builder: (BuildContext context, AsyncSnapshot snapshot) {
                  if (snapshot.hasData) {
                    var jsonResult = json.decode(snapshot.data);

                    for (var end in jsonResult) {
                      _markers.add(
                        Marker(
                          markerId: MarkerId((end['truck_name'].length > 0 ? end['truck_name'] : 'Caminhão de Lixo')),
                          draggable: false,
                          icon: BitmapDescriptor.fromAsset("assets/pngs/caminhaozinho.png"),
                          position: LatLng(double.parse(end['truck_lat']), double.parse(end['truck_lng'])),
                        ),
                      );
                    }

                    return Container(
                      height: MediaQuery.of(context).size.height,
                      width: MediaQuery.of(context).size.width,
                      child: GoogleMap(
                        myLocationEnabled: true,
                        myLocationButtonEnabled: false,
                        minMaxZoomPreference: MinMaxZoomPreference(14, 17),
                        onMapCreated: _onMapCreated,
                        initialCameraPosition: CameraPosition(
                          target: LatLng(lat, long),
                          zoom: 17.0,
                        ),
                        compassEnabled: true,
                        markers: Set.from(_markers),
                      ),
                    );
                  } else {
                    return MaterialApp(
                      home: Scaffold(
                        body: Container(
                          child: Center(
                            child: CircularProgressIndicator(
                              backgroundColor: Colors.green
                            ),
                          ),
                        ),
                      ),
                    );
                  }
                }
              ),

Quando eu rodo a aplicação no meu emulador eu recebo o seguinte log:

I/flutter ( 6163): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ I/flutter ( 6163): The following StateError was thrown building MediaQuery(MediaQueryData(size: Size(411.4, 683.4), I/flutter ( 6163): devicePixelRatio: 2.6, textScaleFactor: 1.0, platformBrightness: Brightness.light, padding: I/flutter ( 6163): EdgeInsets(0.0, 24.0, 0.0, 0.0), viewPadding: EdgeInsets(0.0, 24.0, 0.0, 0.0), viewInsets: I/flutter ( 6163): EdgeInsets.zero, alwaysUse24HourFormat: false, accessibleNavigation: false, disableAnimations: I/flutter ( 6163): false, invertColors: false, boldText: false)): I/flutter ( 6163): Bad state: Stream has already been listened to. I/flutter ( 6163): I/flutter ( 6163): When the exception was thrown, this was the stack: I/flutter ( 6163): #3 _CompleterStream.listen (package:async/src/stream_completer.dart:133:31) I/flutter ( 6163): #7 _StreamBuilderBaseState._subscribe (package:flutter/src/widgets/async.dart:135:37) I/flutter ( 6163): #8 _StreamBuilderBaseState.initState (package:flutter/src/widgets/async.dart:109:5) I/flutter ( 6163): #9 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4033:58) I/flutter ( 6163): #10 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5) I/flutter ( 6163): #11 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #12 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5198:32) I/flutter ( 6163): #13 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #14 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #15 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #16 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #17 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5) I/flutter ( 6163): #18 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5) I/flutter ( 6163): #19 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #20 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #21 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #22 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #23 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5) I/flutter ( 6163): #24 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5) I/flutter ( 6163): #25 ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4279:11) I/flutter ( 6163): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #27 MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5198:32) I/flutter ( 6163): #28 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #29 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #30 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #31 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #32 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5) I/flutter ( 6163): #33 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4053:11) I/flutter ( 6163): #34 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5) I/flutter ( 6163): #35 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #36 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #37 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #38 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #39 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5) I/flutter ( 6163): #40 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5) I/flutter ( 6163): #41 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #42 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #43 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #44 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #45 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5) I/flutter ( 6163): #46 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4053:11) I/flutter ( 6163): #47 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5) I/flutter ( 6163): #48 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #49 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #50 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5092:14) I/flutter ( 6163): #51 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #52 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #53 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #54 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #55 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5) I/flutter ( 6163): #56 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5) I/flutter ( 6163): #57 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #58 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #59 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:5092:14) I/flutter ( 6163): #60 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #61 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #62 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #63 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #64 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5) I/flutter ( 6163): #65 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4053:11) I/flutter ( 6163): #66 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5) I/flutter ( 6163): #67 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #68 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #69 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #70 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #71 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5) I/flutter ( 6163): #72 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4053:11) I/flutter ( 6163): #73 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5) I/flutter ( 6163): #74 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #75 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #76 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #77 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #78 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5) I/flutter ( 6163): #79 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5) I/flutter ( 6163): #80 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #81 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #82 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #83 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #84 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5) I/flutter ( 6163): #85 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5) I/flutter ( 6163): #86 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #87 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #88 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #89 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #90 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5) I/flutter ( 6163): #91 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4053:11) I/flutter ( 6163): #92 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5) I/flutter ( 6163): #93 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14) I/flutter ( 6163): #94 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12) I/flutter ( 6163): #95 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5099:14) I/flutter ( 6163): #96 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #97 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #98 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #99 StatelessElement.update (package:flutter/src/widgets/framework.dart:3981:5) I/flutter ( 6163): #100 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #101 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5099:14) I/flutter ( 6163): #102 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #103 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5099:14) I/flutter ( 6163): #104 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #105 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5099:14) I/flutter ( 6163): #106 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #107 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5099:14) I/flutter ( 6163): #108 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #109 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #110 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #111 StatefulElement.update (package:flutter/src/widgets/framework.dart:4085:5) I/flutter ( 6163): #112 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #113 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #114 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #115 StatelessElement.update (package:flutter/src/widgets/framework.dart:3981:5) I/flutter ( 6163): #116 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #117 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #118 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #119 StatefulElement.update (package:flutter/src/widgets/framework.dart:4085:5) I/flutter ( 6163): #120 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #121 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5099:14) I/flutter ( 6163): #122 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #123 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #124 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #125 ProxyElement.update (package:flutter/src/widgets/framework.dart:4219:5) I/flutter ( 6163): #126 _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:94:11) I/flutter ( 6163): #127 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #128 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5099:14) I/flutter ( 6163): #129 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #130 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #131 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #132 StatefulElement.update (package:flutter/src/widgets/framework.dart:4085:5) I/flutter ( 6163): #133 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #134 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #135 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #136 StatelessElement.update (package:flutter/src/widgets/framework.dart:3981:5) I/flutter ( 6163): #137 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #138 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5099:14) I/flutter ( 6163): #139 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #140 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) I/flutter ( 6163): #141 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #142 ProxyElement.update (package:flutter/src/widgets/framework.dart:4219:5) I/flutter ( 6163): #143 Element.updateChild (package:flutter/src/widgets/framework.dart:2876:15) I/flutter ( 6163): #144 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16) E/eglCodecCommon( 6163): glUtilsParamSize: unknow param 0x00008741 E/eglCodecCommon( 6163): glUtilsParamSize: unknow param 0x00008741 E/eglCodecCommon( 6163): glUtilsParamSize: unknow param 0x00008741 E/eglCodecCommon( 6163): glUtilsParamSize: unknow param 0x00008741 I/flutter ( 6163): #145 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5) I/flutter ( 6163): #146 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2340:33) I/flutter ( 6163): #147 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:700:20) I/flutter ( 6163): #148 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:285:5) I/flutter ( 6163): #149 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1016:15) I/flutter ( 6163): #150 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:958:9) I/flutter ( 6163): #151 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:874:5) I/flutter ( 6163): #155 _invoke (dart:ui/hooks.dart:236:10) I/flutter ( 6163): #156 _drawFrame (dart:ui/hooks.dart:194:3) I/flutter ( 6163): (elided 9 frames from package dart:async) I/flutter ( 6163): ════════════════════════════════════════════════════════════════════════════════════════════════════ I/flutter ( 6163): Another exception was thrown: The _ScaffoldLayout custom multichild layout delegate forgot to lay out the following child: I/flutter ( 6163): Another exception was thrown: Bad state: Stream has already been listened to. I/flutter ( 6163): Another exception was thrown: The _ScaffoldLayout custom multichild layout delegate forgot to lay out the following children: Syncing files to device Android SDK built for x86... 7.306ms (!)

Alguém saberia como me ajudar?

1 Resposta 1

1

Imagens do emulador do estado da tela são importantes !!!

Problema esta na interface, esta dando media.query error e overflow, por isso o motivo da tela estar branca (como você descreveu).

Tente rever sua interface e as medidas dela

Se o problema estiver nos pacotes

flutter clean
flutter run

Você deve fazer log-in para responder a esta pergunta.

Esta não é a resposta que você está procurando? Pesquise outras perguntas com a tag .