Flutter 容器 (1)

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,
        ),
      ),
    );
  }
}

Keep learning
原文地址:https://www.cnblogs.com/leslie1943/p/13364722.html