Skip to content

Instantly share code, notes, and snippets.

@jmolins
Forked from slightfoot/fill_viewport.dart
Created February 18, 2018 23:31
Show Gist options
  • Save jmolins/3c9e51a42274c7e00ca5398c39efc9f1 to your computer and use it in GitHub Desktop.
Save jmolins/3c9e51a42274c7e00ca5398c39efc9f1 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.
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