谷歌地图 dequeueBuffer:BufferQueue 已被废弃

HPr*_*ure 5 dart flutter

我在使用 Google 地图小部件时遇到了一些麻烦。
简而言之,我有 3 个页面,带有底部导航栏的主页,地图页面 - 在 Scaffold 主体中带有 GoogleMap 的基本状态小部件,以及另一个页面。每次我从地图页面切换得太快时,我都会收到此错误,整个应用程序都冻结了。

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

据我了解,这归结为在 SurfaceTexture 破坏后地图继续加载的事实,如下所示:https ://stackoverflow.com/a/22490648/11318016
我看到有办法在 android 上解决它,但我没有找到一种在颤振中处理它的方法。

Jos*_*una 8

我遇到了同样的问题,我修复了它,在我的 statefulwidget 中添加了“with AutomaticKeepAliveClientMixin”。它将使您的小部件永不消亡,并使您免于出现过多帧的异常。这:E/BufferQueueProducer( 9243): [SurfaceTexture-0-9243-14] dequeueBuffer: BufferQueue has been abandoned仍将在调试终端中,但这不是错误。

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)),
          )
        ],
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)


小智 -2

该错误是由于 API 密钥格式错误引起的。确保您的 API 密钥正确。