用于在垂直位置中显示子项的组件。若子项要填充水平空间,需要将子项置于Expanded组件(用于扩展Row、Column或Flex子项的组件)中。
列组件是不能滚动的(通常将列中溢出的子项视为错误的)。如果需要设置组件在没有足够空间滚动,考虑使用ListView。
官方示例将垂直位置划分为三块,前两个放置文本信息,后一个放置Flutter logo。
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text("Column组件"),
),
body: Column(
children: <Widget>[
Text("Deliver features faster"),
Text("Craft beautiful UIs"),
Expanded(
child: FittedBox(
fit: BoxFit.contain,
child: FlutterLogo(),
),
)
],
),
),
);
}
}

我们可以通过crossAxisAlignment设置子组件的对齐方式,可以通过MainAxisSize.min设置列缩小以适合子组件。
Column属性

网友评论