-
-
Save fnicastri/efd64d4a33e6d8597e6755bfe7ffcf61 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.
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 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