Center

用于使子Widget居中的Widget。包含三个属性:

  • widthFactor

    宽度因子,表示为该Widget宽度比子Widget宽度的倍数。

  • heightFactor

    高度因子,表示为该Widget高度比子Widget高度的倍数。

  • child

    包含的子Widget。

Widget getCenter() {
    return Container(
      color: Colors.grey,
      child: Center(
        widthFactor: 3,
        heightFactor: 2,
        child: Container(
           100,
          height: 100,
          alignment: Alignment.center,
          color: Colors.redAccent,
          child: Text('This is Center widget demo'),
        ),
      ),
    );
  }
原文地址:https://www.cnblogs.com/timba1322/p/12487531.html