【问题标题】:Trying to embed a platform view but the PaintContext does not support embedding尝试嵌入平台视图,但 PaintContext 不支持嵌入
【发布时间】:2020-01-15 10:17:23
【问题描述】:

我正在尝试将 google 地图添加到我的项目中,但地图是 self 不是 在ios模拟器上显示

这是我在运行小部件时得到的结果

[VERBOSE-2:platform_view_layer.cc(38)] Trying to embed a platform view but the PaintContext does not support embedding
Google Maps SDK for iOS version: 3.4.0.0
    [C1.1 3DBF24C4-522B-4596-B9CD-9F9A538547E8 172.20.10.4:51304<->172.217.22.110:443]
    Connected Path: satisfied (Path is satisfied), interface: en0
    Duration: 0.791s, DNS @0.009s took 0.078s, TCP @0.091s took 0.163s, TLS took 0.337s
    bytes in/out: 4277/672, packets in/out: 9/8, rtt: 0.155s, retransmitted packets: 0, out-of-order packets: 0

我已经尝试添加

<key>io.flutter.embedded_views_preview</key>
    <true/>

到 info.plist ,

还将地图 SDK 更新到最新版本

这是我的代码

 static const LatLng _center = const LatLng(45.521563, -122.677433);

  void _onMapCreated(GoogleMapController controller) {
    _controller.complete(controller);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Maps Sample App'),
          backgroundColor: Colors.green[700],
        ),
        body: GoogleMap(
          onMapCreated: _onMapCreated,
          initialCameraPosition: CameraPosition(
            target: _center,
            zoom: 11.0,
          ),
        ),
      ),
    );
  }

【问题讨论】:

    标签: flutter flutter-dependencies


    【解决方案1】:

    尝试退出模拟器然后重新启动,flutter run 再次。 我认为-R 热重启不会重新加载Info.plist

    【讨论】:

    • 罗文辉您好,欢迎来到 Stack Overflow!请您在答案中添加更多细节吗?也许解释一下这如何帮助解决问题?
    【解决方案2】:

    我对这个解决方案几乎没有改进,我正在尝试使用 webview 插件,但我遇到了同样的错误。 我看到我的 info.plist 没有这个条目:

    ```
        <key>io.flutter.embedded_views_preview</key>
        <true/>
    ```
    

    当我尝试直接在 androidstudio info.plist 文件中更改文件时,当热重新加载文件时,该文件将恢复为原始值。 在Xcode中打开ios项目,使用GUI更改此项后,错误解决。

    我希望它对其他人有用。

    谢谢

    也在:https://github.com/flutter/flutter/issues/39616

    【讨论】:

      【解决方案3】:

      只需在info.plist 文件中添加此键值对即可。

      <key>io.flutter.embedded_views_preview</key>
      <true/>
      

      【讨论】:

        猜你喜欢
        • 2019-09-08
        • 2020-03-02
        • 2019-10-17
        • 1970-01-01
        • 2014-03-21
        • 2019-01-21
        • 1970-01-01
        • 1970-01-01
        • 2011-06-02
        相关资源
        最近更新 更多