Skip to content

Conversation

@Piinks
Copy link
Contributor

@Piinks Piinks commented Jun 12, 2019

Description

Follow-up to flutter/engine#8848 and #33999
This PR addresses the issue of a layout incorrectly shifting as a result of the bottom padding being consumed by an obstruction (i.e. a software keyboard).
This error presented in:

Scaffold

resizeToAvoidBottomInsets: false

BottomNavigationBar, SnackBar and PersistentFooter buttons affected.
An automatic flag has been added to the Scaffold class, maintainBottomViewPadding, that will follow the viewPadding of these elements when the viewInsets consumes bottom padding.

SafeArea

An optional flag has been added, maintainBottomViewPadding, to determine if viewPadding should be used over padding when there is an obstruction on the screen. In most cases, the current behavior is desirable, so is the default behavior. When the appearance of a software keyboard causes a layout shift, setting this to true will prevent that change.

Other cases

CupertinoTabScaffold and CupertinoPageScaffold both have the resizeToAvoidBottomInsets property, but do not produce this bug. Tests have been added to prevent possible occurrence.
In Scaffold, the FloatingActionButton and BottomSheet were unaffected by layout shifts, and tests have been added for these cases as well.

Related Issues

Fixes #29941

Tests

  • In cupertino/tab_scaffold_test.dart
    • Tab contents bottom padding are not consumed by viewInsets when resizeToAvoidBottomInset overridden
  • In cupertino/scaffold.test
    • Contents bottom padding are not consumed by viewInsets when resizeToAvoidBottomInset overridden
  • In material/scaffold_test.dart
    • Scaffold BottomNavigationBar bottom padding is not consumed by viewInsets.
    • Persistent bottom buttons bottom padding is not consumed by viewInsets
    • BottomSheet bottom padding is not consumed by viewInsets
    • Floating Action Button bottom padding not consumed by viewInsets
  • In material/snack_bar_test.dart
    • SnackBar bottom padding is not consumed by viewInsets
  • In widgets/safe_area_test.dart
    • group: SafeArea maintains bottom viewPadding when specified for consumed bottom padding
      • SafeArea alone
      • SafeArea with nested Scaffold

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • No, this is not a breaking change.

@Piinks Piinks added framework flutter/packages/flutter repository. See also f: labels. work in progress; do not review labels Jun 12, 2019
@Piinks Piinks self-assigned this Jun 12, 2019
@Piinks Piinks changed the title WIP - Preserving SafeArea : Part 2 Preserving SafeArea : Part 2 Jun 13, 2019
@Piinks Piinks requested a review from dnfield June 25, 2019 16:29
Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo nit. Feel free to take it or leave it :)

@Piinks Piinks merged commit f9118c0 into flutter:master Jun 26, 2019
@Piinks Piinks deleted the paddingFix branch July 9, 2019 17:07
johnsonmh pushed a commit to johnsonmh/flutter that referenced this pull request Jul 30, 2019
* WIP

* Added tests and updated SafeArea implementation.

* Analyzer nits

* Review feedback

* Updated for SnackBar and PersistentFooterButton cases, added tests to check other potential spots.

* doc addition for SafeArea

* Typos
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

customer: solaris framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bottom notch (iPhone X) not avoided by SafeArea when the Keyboard is open

4 participants