Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems with returning to App using two Screens with Google Maps

Seems to be a more severe bug with flutte google maps. Is a duplicate of #25653

Update 8th August: Current Progress:

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"

Updated on 5th August, getting closer to the real problem

Explanation of the Problem:

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.

Addition:

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.

What I tried so far to get it to work but didn't work:

  1. Release Mode => Same Problem
  2. Disabled Navigation Transition (like this)
  3. async await url launch
  4. Building on IOs 12.3 & 12.4
  5. Building the Maps Widget inside a Future Builder

Steps to reproduce:

  1. 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)

  2. Copy the CodeSnippet in a flutter project and build on IOs.

  3. Tap on the Marker

  4. Tap on Button "Start Navigation" or leave the App
  5. Tap in Apple Maps on the upper left corner redirecting to the App or reopen the App
  6. Your back in the info screen, tap on the left Arrow in the upper left corner
  7. Only a white screen is visible

Code:

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,
              ),
            ),
          ),
        ),
      ),
    );
  }
}

flutter doctor:

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>
like image 880
Markus Hein Avatar asked Aug 05 '19 14:08

Markus Hein


People also ask

Why is my Google Maps acting weird?

You may need to update your Google Maps app, connect to a stronger Wi-Fi signal, recalibrate the app, or check your location services. You can also reinstall the Google Maps app if it isn't working, or simply restart your iPhone or Android phone.

How do I reset my Google Maps app?

Procedure for Android 4.1. Go into the applications manager. Press on the options button (bottom left of screen) to display a menu. Press on Reset preferences. Having read the warning message, press on the Reset applications button.


2 Answers

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.

like image 67
Sukhi Avatar answered Oct 24 '22 08:10

Sukhi


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.

like image 38
LuisThein Avatar answered Oct 24 '22 09:10

LuisThein