Flutter 容器 (1) - Center

Center容器用来居中widget

import 'package:flutter/material.dart';

class AuthList extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('代码测试'),
        centerTitle: true,
      ),
      body: Center(
//        widthFactor: 5.0,  // 若该值为空,该组件宽度会尽可能大;若不为空,该组件的宽度就是子节点宽度的多少倍
        heightFactor: 1.0, // 若该值为空,该组件高度会尽可能大;若不为空,该组件的宽度就是子节点宽度的多少倍
        child: Text(
          '居中文本 居中文本 居中文本',
          style: TextStyle(color: Colors.red,fontSize: 15),
          maxLines: 2,
        ),
      ),
    );
  }
}

posted @ 2020-07-23 10:12  荣光无限  阅读(179)  评论(0编辑  收藏  举报