Skip to content

Instantly share code, notes, and snippets.

@slightfoot
Created May 2, 2018 15:38
Show Gist options
  • Save slightfoot/ac6f8bbd23fb2b1b3d9096dab2c0dd01 to your computer and use it in GitHub Desktop.
Save slightfoot/ac6f8bbd23fb2b1b3d9096dab2c0dd01 to your computer and use it in GitHub Desktop.
ScrollView With Height for Flutter. Simple ScrollView with its content having a minimum height of the ScrollView's parent. This allows you to space out your components inside your ScrollView to fit the avaliable space and not have them "squish up" when the soft keyboard (IME) appears.
class ScrollViewWithHeight extends StatelessWidget {
final Widget child;
const ScrollViewWithHeight({Key key, this.child}) : super(key: key);
@override
Widget build(BuildContext context) {
return new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) {
return new SingleChildScrollView(
child: new ConstrainedBox(
constraints: constraints.copyWith(minHeight: constraints.maxHeight, maxHeight: double.infinity),
child: child,
),
);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment