Created
February 15, 2020 17:02
-
-
Save ryanlid/7fa7c962b5436d3a8deef3d4075d1473 to your computer and use it in GitHub Desktop.
ConstrainedBox 限定最大最小宽高布局
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'; | |
void main() { | |
runApp(MaterialApp( | |
title: "ConstrainedBox限定最大最小宽高布局", | |
home: LayoutDemo(), | |
)); | |
} | |
class LayoutDemo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("ConstrainedBox限定最大最小宽高布局"), | |
), | |
body: ConstrainedBox( | |
// 设置限定值 | |
constraints: BoxConstraints( | |
minWidth: 150.0, | |
minHeight: 220.0, | |
maxWidth: 220.0, | |
maxHeight: 220.0, | |
), | |
// 子容器 | |
child: Container( | |
width: 300.0, | |
height: 300.0, | |
color: Colors.green, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment