Created
February 15, 2020 17:10
-
-
Save ryanlid/98fa1996b8cb95da62a2e9076b02d6ad to your computer and use it in GitHub Desktop.
FractionallySizedBox 百分比布局
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: "FractionallySizedBox百分比布局", | |
home: LayoutDemo(), | |
)); | |
} | |
class LayoutDemo extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("FractionallySizedBox百分比布局"), | |
), | |
body: Container( | |
color: Colors.blueGrey, | |
height: 200.0, | |
width: 200.0, | |
child: FractionallySizedBox( | |
alignment: Alignment.topLeft, | |
// 宽度因子 | |
widthFactor: 0.5, | |
// 高度因子 | |
heightFactor: 1.5, | |
child: Container( | |
color: Colors.green, | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment