1 import 'package:flutter/material.dart';
2
3 class LayoutDemo extends StatelessWidget{
4 @override
5 Widget build(BuildContext context) {
6 // TODO: implement build
7 return new Scaffold(
8 appBar: new AppBar(
9 title: new Text('FittedBox缩放布局示例'),
10 ),
11 body: new Container(
12 color: Colors.grey,
13 width: 250.0,
14 height: 250.0,
15 child: new FittedBox(
16 fit: BoxFit.fill,// 更改此处属性 scalDown/fitHeight/cover/fitWidth/none/fill/contain
17 alignment: Alignment.topLeft,
18 child: new Container(
19 color: Colors.deepOrange,
20 child: new Text('缩放布局'),
21 ),
22 ),
23 ),
24 );
25 }
26 }
27
28 void main(){
29 runApp(
30 new MaterialApp(
31 title: 'FittedBox缩放布局',
32 home: new LayoutDemo(),
33 ),
34 );
35 }