Skip to content

[IOS] SafeArea maintainBottomViewPadding is not respected when keyboard viewInsets are animated #97609

@joellurcook

Description

@joellurcook

This issue has been introduced as a result of the changes to the flutter engine (iOS) made in PR 29281 (flutter/engine#29281). Those changes are in use on the current master and dev branch of this project.

It is now possible for MediaqQuery viewInsets.bottom to be >0 AND for padding.bottom >0 during the keyboard transition. This results in the maintainBottomViewPadding property being ignored within SafeArea build() at various times during the animation.

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Tap on the TextField to reveal the software keyboard
  3. Tap 'done' to remove the software keyboard

Expected results:
The keyboard should overlay the app and not affect the layout of any widgets. In particular, the SafeArea padding at the bottom of the orange widget should remain unchanged regardless of the viewInsets.bottom value created by the keyboard since maintainBottomViewPadding is set to true.

Actual results:
During animation, the orange widget 'jumps' downward. It is laid out differently during the animation indicating that the bottom viewPadding is not always respected, despite maintainBottomViewPadding being set to true.

Code sample
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      appBar: AppBar(
        title: const Text('SafeArea Demo'),
      ),
      body: Center(
        child: Column(
          children: <Widget>[
            const Expanded(
                child: Padding(
              padding: EdgeInsets.only(top: 20.0),
              child: Text("This scaffold has resizeToAvoidBottomInset=false"),
            )),
            SafeArea(
              maintainBottomViewPadding: true,
              child: Container(
                color: const Color.fromARGB(255, 255, 72, 0),
                height: 500,
                child: Column(
                  children: const [
                    Text(
                      'This container is surrounded by a SafeArea \n with maintainBottomViewPadding=true',
                      style: TextStyle(fontWeight: FontWeight.bold),
                    ),
                    SizedBox(width: 200, child: TextField()),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
Logs
No relevant runtime logs
No issues found! (ran in 1.8s)
[✓] Flutter (Channel master, 2.10.0-1.0.pre.373, on macOS 12.1 21C52 darwin-x64, locale en-GB)
    • Flutter version 2.10.0-1.0.pre.373 at /Users/joellurcook/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision a22cf5d6b9 (28 minutes ago), 2022-02-02 09:16:05 +0100
    • Engine revision 0bd729b972
    • Dart version 2.17.0 (build 2.17.0-74.0.dev)
    • DevTools version 2.10.0

[!] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /Users/joellurcook/Library/Android/sdk
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio 2.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] IntelliJ IDEA Community Edition (version 2021.1.3)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.63.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.34.0

[✓] Connected device (2 available)
    • iPhone 13 (mobile) • 63C9A42F-6841-4F83-8922-DCAE0C900EBE • ios            • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator)
    • Chrome (web)       • chrome                               • web-javascript • Google Chrome 97.0.4692.99

[✓] HTTP Host Availability
    • All required HTTP hosts are available

! Doctor found issues in 1 category.
Simulator.Screen.Recording.-.iPhone.13.-.2022-02-01.at.21.01.35.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: layoutSystemChrome and Framework's Layout Issuesc: regressionIt was better in the past than it is nowengineflutter/engine related. See also e: labels.found in release: 2.10Found to occur in 2.10found in release: 2.8Found to occur in 2.8frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-iosiOS applications specificallyr: fixedIssue is closed as already fixed in a newer versionwaiting for PR to land (fixed)A fix is in flight

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions