import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return MaterialApp(
title: "FittedBox缩放布局",
home: Scaffold(
appBar: AppBar(
title: Text('FittedBox缩放布局'),
),
body: Container(
color: Colors.grey,
width: 250,
height: 250,
//缩放布局
child: FittedBox(
fit: BoxFit.contain,
//对亲属性
alignment: Alignment.topLeft,
child: Container(
color: Colors.lightBlue,
child: Text('还有谁'),
),
),
)),
);
}
}
网友评论