Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created February 15, 2020 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanlid/98fa1996b8cb95da62a2e9076b02d6ad to your computer and use it in GitHub Desktop.
Save ryanlid/98fa1996b8cb95da62a2e9076b02d6ad to your computer and use it in GitHub Desktop.
FractionallySizedBox 百分比布局
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