Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trying to embed a platform view but the PaintContext does not support embedding

I'm trying to add google maps to my project ,but the map is self is not showing on ios simulator

here is what I get when running the widget

[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

I have tried to to add

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

to info.plist ,

also update the map SDK to the latest version

here's my code

 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,
          ),
        ),
      ),
    );
  }
like image 723
Turki Alhazzani Avatar asked Sep 13 '19 14:09

Turki Alhazzani


3 Answers

I little improve on this solution, I am trying to use the webview plugin and I've faced the same error. I saw that my info.plist haven`t had the entry:

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

When I try to change the file directly in the androidstudio info.plist file, when hot reloading the file is reverted to the original value. After opening the ios project in the Xcode and using the GUI to change this entry, the error was solved.

I hope it can be useful for someone else.

Thanks

Also in: https://github.com/flutter/flutter/issues/39616

like image 107
Helton Isac Avatar answered Dec 23 '22 13:12

Helton Isac


Try quit simulator then restart, flutter run again. I think -R hot restart doesn't reload Info.plist.

like image 43
Wenhui Luo Avatar answered Dec 23 '22 13:12

Wenhui Luo


Just add this key value pair in info.plist file.

<key>io.flutter.embedded_views_preview</key>
<true/>
like image 33
Vivek Avatar answered Dec 23 '22 14:12

Vivek