Created
February 16, 2018 05:32
-
-
Save slightfoot/2baa44e8a35f5226cd4c9f41caf81d5f to your computer and use it in GitHub Desktop.
"Android Fill Viewport" style of content for Flutter, where even when the keyboard appears the content flows behind.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SomeWidgetState extends State<SomeWidget> { | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold(body: new LayoutBuilder(builder: _buildContent)); | |
} | |
Widget _buildContent(BuildContext context, BoxConstraints constraints) { | |
if (constraints.hasBoundedHeight) { | |
constraints = constraints.copyWith(maxHeight: constraints.maxHeight + | |
MediaQuery.of(context).viewInsets.vertical); | |
} | |
return new SingleChildScrollView( | |
child: new ConstrainedBox( | |
constraints: constraints, | |
child: new Column( | |
children: <Widget>[ | |
/* ... */ | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How do you prevent this from causing an overflow error when you change your device orientation?