Skip to content

SafeArea.maintainBottomViewPadding should be true by default #59204

@Piinks

Description

@Piinks

Found while investigating #58942

When Scaffold.resizeToAvoidBottomInsets: false, the layout will shift when the keyboard opens if there is a SafeArea in the Scaffold's body.

This is because in scaffold.dart:

// The minimum insets for contents of the Scaffold to keep visible.

    final EdgeInsets minInsets = mediaQuery.padding.copyWith(
      bottom: _resizeToAvoidBottomInset ? mediaQuery.viewInsets.bottom : 0.0,
    );

You can see in the gif below that the white safe space under the keyboard goes away when it opens.

ezgif com-video-to-gif

Reproduction

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        resizeToAvoidBottomInset: false,
        appBar: AppBar(title: Text('Demo')),
        body: SafeArea(
          child: 
          Container(
            color: Colors.yellow,
            child: Center(child: TextField())
          ),
        ),
        floatingActionButton: RaisedButton(
          onPressed: () {},
          child: Text('Button'),
        ),
      ),
    );
  }
}

flutter doctor

[✓] Flutter (Channel master, 1.19.0-6.0.pre.51, on Mac OS X 10.15.4 19E287, locale en-US)
    • Flutter version 1.19.0-6.0.pre.51 at /Users/katelovett/github/flutter
    • Framework revision 75fd73d818 (56 minutes ago), 2020-06-10 13:49:35 -0700
    • Engine revision e8c13aa012
    • Dart version 2.9.0 (build 2.9.0-14.0.dev 5c1376615e)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/katelovett/Library/Android/sdk
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.3.1, Build version 11C505
    • CocoaPods version 1.9.1

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 36.1.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

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

[✓] Connected device (1 available)
    • iPhone 11 Pro Max • A8FFA716-A67B-4468-B92B-F2B61F2306A0 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: layoutSystemChrome and Framework's Layout Issuesa: qualityA truly polished experiencec: API breakBackwards-incompatible API changesc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterframeworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions