Flexible 设置每个控制所占的空间比例
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Flexible Demo"),
),
body: Container(
child: Center(
child: Column(
children: [
Flexible(
flex: 2,
fit: FlexFit.loose,
child: Container(
//height: 100,
color: Colors.cyan,
),
),
Flexible(
flex: 3,
child: Container(
//height: 100,
color: Colors.indigo,
),
),
Flexible(
flex: 1,
child: Container(
// height: 100,
color: Colors.teal,
),
),
],
),
),
),
);
}
}