Last active
March 28, 2019 02:37
-
-
Save Nash0x7E2/6d4b5d45d4146eb2e35f2f34f4074fbe to your computer and use it in GitHub Desktop.
Used to constrain the child of a scrollable to the max height of the view.
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
import 'package:flutter/material.dart'; | |
class ConstrainedView extends StatelessWidget { | |
const ConstrainedView({Key key, this.child}) : super(key: key); | |
final Widget child; | |
@override | |
Widget build(BuildContext context) { | |
return LayoutBuilder( | |
builder: (BuildContext context, BoxConstraints constraints) { | |
return Padding( | |
padding: MediaQuery.of(context).viewInsets, | |
child: SingleChildScrollView( | |
child: ConstrainedBox( | |
constraints: BoxConstraints( | |
maxHeight: constraints.maxHeight, | |
minHeight: constraints.maxHeight), | |
child: child, | |
), | |
), | |
); | |
}, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment