Repository navigation
SafeArea.maintainBottomViewPadding should be true by default #59204
Description
Activity
- addedframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packagesa: qualityA truly polished experienceA truly polished experience
on Jun 10, 2020 Well gosh I was just missing
SafeArea.maintainBottomViewPadding: true. Which I added a year ago in #34298
Hm.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( maintainBottomViewPadding: true, child: Container( color: Colors.yellow, child: Center(child: TextField()) ), ), floatingActionButton: RaisedButton( onPressed: () {}, child: Text('Button'), ), ), ); } }
Reacted by ViktorKirjanovI think maybe SafeArea.maintainBottomViewPadding should be true by default. I am going to explore this some more.
- changed the title
[-]Keyboard causes Scaffold+SafeArea to resize when resizeToAvoidBottomInsets=false[/-][+]SafeArea.maintainBottomViewPadding should be true by default[/+]on Jun 10, 2020 - addedhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on
on Jul 17, 2020 - addedc: API breakBackwards-incompatible API changesBackwards-incompatible API changesa: layoutSystemChrome and Framework's Layout IssuesSystemChrome and Framework's Layout Issuesand removedp: material_uimaterial_ui package in flutter/packagesmaterial_ui package in flutter/packages
on Jul 21, 2020 I've looked at this a bit and it seems that this would have much larger implications than I originally thought.
SafeArea.maintainViewPaddingwas added to incorporate the, also new,MediaQuery.viewPadding. SinceMediaQuery.viewPaddingis an ATF addition, it is not widely used throughout the framework. Often where a widget should use theviewPadding, it usespaddingwith special handling for edge cases thatviewPaddingwould address, for example, theScaffoldaccounts for maintaining the padding when arranging the variousScaffoldelements :void _addIfNonNull( So while changing this may seem trivial, it would actual require large scale refactoring across the framework. For example,
BottomNavigationBarwould be broken in that, instead of theTextFieldshifting down in the example above, theBottomNavigationBarwould shift up. A lot of care would need to be taken in this change to check every potentially affected widget.I think that
viewPaddingaddressing the edge case it came in to fix (#29941) is ok for now. The true yak shave here would be re-factoringMediaQueryand all the affected widgets in one go to avoid breaking while achieving the desired default behavior in the example above, clearing up what is a bit of confusing API. I've added it to #24722 as a large breaking change that would improve the API surface.I won't be undertaking this currently, so I'm removing my assignment. I'll leave this open for discussion & future work.
- addedc: proposalA detailed proposal for a change to FlutterA detailed proposal for a change to Flutterand removedhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work on
on Jul 30, 2020 - addedc: new featureNothing broken; request for a new capabilityNothing broken; request for a new capability
on Apr 14, 2021 - addedP3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectand removed
on Jun 28, 2023 - addedteam-frameworkOwned by Framework teamOwned by Framework teamtriaged-frameworkTriaged by Framework teamTriaged by Framework team
on Jul 8, 2023
Found while investigating #58942
When
Scaffold.resizeToAvoidBottomInsets: false, the layout will shift when the keyboard opens if there is aSafeAreain theScaffold's body.This is because in scaffold.dart:
flutter/packages/flutter/lib/src/material/scaffold.dart
Line 2494 in e13b44d
You can see in the gif below that the white safe space under the keyboard goes away when it opens.
Reproduction
flutter doctor