Center介绍

Center就是将子组件进行一个居中展现,它继承自Align,因为Align默认的对齐形式是居中的,所以它能实现居中成果,如果Center的尺寸没有受到限制,那么它将尽可能大。

示例代码

本文中很多成果都没有截图,可下载源代码运行我的项目 源代码地址,或者通过视频教程查看 视频教程地址

什么状况下应用Center?

当咱们须要对子组件进行居中的时候应用Center

Center的属性和阐明

字段属性形容
widthFactordouble宽度系数
heightFactordouble高度系数
childWidget子组件

Center应用

import 'package:flutter/material.dart';class CenterExample extends StatefulWidget {  @override  _CenterExampleState createState() => _CenterExampleState();}class _CenterExampleState extends State<CenterExample> {  @override  Widget build(BuildContext context) {    return Scaffold(      appBar: AppBar(        title: Text("AlignExample"),      ),      body: Center(        child: Text("Jimi"),      ),    );  }}

成果展现

完结

咱们对Flutter的所有容器类组件进行了一个解说,那么此篇幅就曾经完结了,在接下来咱们持续解说Flutter的根底类组件。