Skip to content

Instantly share code, notes, and snippets.

@Stmol
Forked from slightfoot/scroll_view_height.dart
Created January 24, 2020 09:40
Show Gist options
  • Save Stmol/53bb387b0c3d62783731d8a8a03cf56a to your computer and use it in GitHub Desktop.
Save Stmol/53bb387b0c3d62783731d8a8a03cf56a 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