Reputation: 614
Tried to fix the bug with Sukhi, but he wasn't able to reproduce the bug. My colleagues all were able to reproduce it, but wheren't able to fix it :P. Did anyone else manage to reproduce it?
Also created a github repo with my code and updated the "what I tried so far"
My problem only occurs on IOs on real devices (not Simulator) on debug and release.
I do use the google Maps widget with some markers. Tapping on on Marker opens another Screen with more Information, another google Maps widget and the possibility to Navigate via url launcher. (I reduced the Screens to only show the widgets causing the problem)
Leaving the app from this screen (by tapping start navigation for example or going to the IOs homescreen) and then comming back to the app leads to an issue.
If i go back to the App homescreen again, only a white screen is shown.
Wrapping the Google Maps Widget in the info Screen in a Flex Widget (Column or Row) even leads to a worse behaviour. When returning to the Apps HomeScreen, additional content of the Flex Widget (for example a Container with Text) will stay visible.
Install google_maps_flutter 0.5.20+1 and url_launcher: 5.0.3 (I know it is not the latest, but thats not the problem)
Copy the CodeSnippet in a flutter project and build on IOs.
Tap on the Marker
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>
Upvotes: 5
Views: 3131
Reputation: 159
I also had a similar issue like yours but was able to find a way to solve it.
Instead of using Navigator.push
use Navigator.pushReplacement
while navigating and set up an onscreen back button to go to homescreen and navigate to homescreen using Navigator.pushReplacement.By
.
This way, you will be able to reload the homescreen again and map loads properly.
Upvotes: 2
Reputation: 36
I can reproduce the issue on an iPhone 6. When launching through Xcode it actually threw this error: Thread 1: EXC_BAD_ACCESS (code=1, address=0x1)
in Runner/Runner/Supporting Files/main.m.
After awaiting the url launches in the onTap functions like this:
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');
}
}
I wasn't able to reproduce the bug again. I guess the Flutter Application is not correctly going into background mode when the url launch isn't awaited.
Upvotes: 2
Reputation: 14195
Ran your code and solved the issue by adding the following key in the info.plist
Key name : io.flutter.embedded_views_preview Type : boolean Value : Yes
When I ran the code on my iPhone 5S, I could see the blank white screen at the beginning (So, not even HomePage() was displayed). There was an error though which was :
[VERBOSE-2:platform_view_layer.cc(19)] Trying to embed a platform view but the PrerollContext does not support embedding
This leads to the issue on Github related to Google Maps plug-in for iOS.
PoC is here for your reference.
Upvotes: 4