尝试使用 Sukhi 修复该错误,但他无法重现该错误。我的同事都能够重现它,但无法修复它:P。有没有其他人设法复制它?
还创建了 github repo with my code并更新了“我到目前为止尝试过的”
我的问题只发生在真实设备(不是模拟器)上的IOs上debug和release。
我确实使用带有一些标记的谷歌地图小部件。点击标记会打开另一个屏幕,其中包含更多信息、另一个谷歌地图小部件以及通过 url 启动器导航的可能性。 (我将屏幕缩小为仅显示导致问题的小部件)
从此屏幕离开应用(例如通过点击开始导航或转到 IO 主屏幕)然后返回应用会导致问题。
如果我再次返回应用主屏幕,则只显示白屏。
将 Google map 小部件包装在 Flex 小部件(列或行)中的信息屏幕中甚至会导致更糟糕的行为。返回到应用程序主屏幕时,Flex Widget 的其他内容(例如带有文本的容器)将保持可见。
安装 google_maps_flutter 0.5.20+1和 url_launcher: 5.0.3 (我知道这不是最新的,但这不是问题)
在 Flutter 项目中复制 CodeSnippet 并在 IO 上构建。
点击标记
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:url_launcher/url_launcher.dart';
import 'dart:io';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
initialRoute: "/",
routes: {
"/": (context) => HomePage(),
},
);
}
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: GoogleMap(
initialCameraPosition: CameraPosition(
target: const LatLng(47.6, 8.8796),
zoom: 7,
),
markers: Set<Marker>()
..add(
Marker(
markerId: MarkerId('hi'),
position: LatLng(47.6, 8.8796),
consumeTapEvents: true,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => InfoScreen()),
);
},
),
),
),
);
}
}
class InfoScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("info Page"),),
body: GoogleMap(
initialCameraPosition: CameraPosition(
target: const LatLng(47.6, 8.8796),
zoom: 7,
),
markers: Set<Marker>()
..add(
Marker(
markerId: MarkerId('hi2'),
consumeTapEvents: true,
position: LatLng(47.6, 8.8796),
onTap: () {
if (Platform.isIOS) {
launch('https://maps.apple.com/?q=47.6,8.8796');
} else {
launch(
'https://www.google.com/maps/search/?api=1&query=47.6,8.8796');
}
},
),
),
),
bottomNavigationBar: BottomAppBar(
elevation: 0,
child: Container(
padding: const EdgeInsets.symmetric(vertical: 19, horizontal: 25),
height: 80,
child: InkWell(
onTap: () {
if (Platform.isIOS) {
launch('https://maps.apple.com/?q=47.6,8.8796');
} else {
launch(
'https://www.google.com/maps/search/?api=1&query=47.6,8.8796');
}
},
child: Text(
'START NAVIGATION',
style: TextStyle(
letterSpacing: 0.35,
fontWeight: FontWeight.w600,
),
),
),
),
),
);
}
}
dynClient36:flutter_app mhein$ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale de-DE)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.2.1)
[✓] iOS tools - develop for iOS devices
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.36.1)
[✓] Connected device (2 available)
• No issues found!
dynClient36:flutter_app mhein$
info plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>flutter_app</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$(FLUTTER_BUILD_NAME)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(FLUTTER_BUILD_NUMBER)</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
<key>NSLocationWhenInUseUsageDescription</key>
<string>JELEJÖLWEKQÖEwkÖ</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Always Permission</string>
<key>io.flutter.embedded_views_preview</key>
<true/>
</dict>
</plist>
最佳答案
运行您的代码并通过在 info.plist 中添加以下键来解决问题
键名:io.flutter.embedded_views_preview 类型: bool 值 值(value):是的
当我在 iPhone 5S 上运行代码时,我可以在开始时看到空白的白屏(因此,甚至没有显示 HomePage())。但是有一个错误:
[VERBOSE-2:platform_view_layer.cc(19)] Trying to embed a platform view but the PrerollContext does not support embedding
这导致 issue在 Github 上与 iOS 版 Google map 插件相关。
PoC 是 here供您引用。
https://stackoverflow.com/questions/57361006/