12

I'm having a little bit of trouble with Google Map widget.
In short, I have 3 pages, home page with bottom navigation bar, map page - basic stateful widget with GoogleMap in Scaffold body, and another page. Everytime I switch from map page too fast I'm getting this error and whole app freezes.

E/BufferQueueProducer( 9243): [SurfaceTexture-0-9243-14] dequeueBuffer: BufferQueue has been abandoned

To my understanding it boils down to the fact that map keep loading after SurfaceTexture destruction, like here: https://stackoverflow.com/a/22490648/11318016
I see there are ways to solve it on android, but I didn't find a way to handle it in flutter.

HPressure
  • 187
  • 3
  • 13

3 Answers3

7

I had the same problem and I fixed it adding "with AutomaticKeepAliveClientMixin" to my statefulwidget. It'll make your widget never die and save you from the exception about present too much frames. This: E/BufferQueueProducer( 9243): [SurfaceTexture-0-9243-14] dequeueBuffer: BufferQueue has been abandoned will be still in debug terminal but it's not an error.

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

class GoThereView extends StatefulWidget {
  @override
  _GoThereViewState createState() => _GoThereViewState();
}

class _GoThereViewState extends State<GoThereView> with AutomaticKeepAliveClientMixin {
  GoogleMapController _controller;

  @override
  bool get wantKeepAlive => true;

  void _onMapCreated(GoogleMapController controller) {
    if( _controller == null )
      _controller = controller;
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Stack(
        children: <Widget>[
          GoogleMap(
            onMapCreated: _onMapCreated,
            initialCameraPosition: CameraPosition(target: LatLng(26.8206, 30.8025)),
          )
        ],
      ),
    );
  }
}
José Luna
  • 307
  • 3
  • 4
0

Just use SingleChildScrollView to wrap your GoogleMap Widget. The flickering will be removed.

return SingleChildScrollView(
  physics: const NeverScrollableScrollPhysics(),
  child:SizedBox(
    width: MediaQuery.of(context).size.width,
    height: MediaQuery.of(context).size.height,
    child: //Your GoogleMap here,
  ),
);
Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Deekshith Xetty
  • 224
  • 3
  • 11
-2

The error has been caused by wrong format of API key. Make sure your API key is correct.

Zoe
  • 27,060
  • 21
  • 118
  • 148