试图用Sukhi修复该错误,但他无法重现该错误。我的同事们都可以复制它,但是无法修复它:P。还有其他人设法复制它吗?
还创建了github repo with my code并更新了“到目前为止我尝试过的”
我的问题仅出现在调试和发行版上的真实设备(不是模拟器)上的 IO 上。 / p>
我确实使用了带有某些标记的google Maps小部件。轻按“标记”会打开另一个屏幕,其中包含更多信息,另一个google Maps小部件以及通过url启动器进行导航的可能性。 (我将屏幕缩小为仅显示导致问题的小部件)
将应用程序从此屏幕上退出(例如,点击开始导航或转到IOs主屏幕),然后返回该应用程序会导致问题。
如果我再次返回到App主屏幕,则仅显示白屏。
在信息屏幕的Flex屏幕小部件(列或行)中包装Google Maps小部件,甚至会导致更糟的行为。返回到Apps HomeScreen时,Flex窗口小部件的其他内容(例如带有文本的容器)将保持可见。
安装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>
答案 0 :(得分:4)
运行您的代码并通过在info.plist中添加以下键来解决该问题
键名:io.flutter.embedded_views_preview 类型:布尔值 值:是
当我在iPhone 5S上运行代码时,我在一开始可以看到空白的空白屏幕(因此,甚至没有显示HomePage())。虽然有一个错误:
[VERBOSE-2:platform_view_layer.cc(19)] Trying to embed a platform view but the PrerollContext does not support embedding
这会导致Github上的issue与iOS版Google Maps插件有关。
PoC为here供您参考。
答案 1 :(得分:1)
我可以在iPhone 6上重现该问题。通过Xcode启动时,它实际上引发了以下错误:Runner / Runner / Supporting Files / main.m中的Thread 1: EXC_BAD_ACCESS (code=1, address=0x1)
。
在等待如下所示的onTap函数中启动url之后:
onTap: () async {
if (Platform.isIOS) {
await launch('https://maps.apple.com/?q=47.6,8.8796');
} else {
await launch('https://www.google.com/maps/search/?api=1&query=47.6,8.8796');
}
}
我无法再次重现该错误。 我猜当不等待url启动时,Flutter应用程序无法正确进入后台模式。
答案 2 :(得分:1)
我也遇到了类似您的问题,但能够找到解决问题的方法。
在导航并设置屏幕上的后退按钮以转到主屏幕并使用Navigator.push
导航到主屏幕时,请使用Navigator.pushReplacement
而不是Navigator.pushReplacement.By
。
这样,您将能够重新加载主屏幕并正确加载地图。