一统天下 flutter - widget 容器类(只能有一个子): Center - 居中对齐

源码 https://github.com/webabcd/flutter_demo
作者 webabcd

一统天下 flutter - widget 容器类(只能有一个子): Center - 居中对齐

示例如下:

lib\widget\container\center.dart

/*
 * Center - 居中对齐
 *
 * Center 继承自 Align,建议能用 Center 就别用 Align
 */

import 'package:flutter/material.dart';

class CenterDemo extends StatelessWidget {
  const CenterDemo({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        width: 50,
        height: 50,
        color: Colors.red,
      ),
    );
  }
}

源码 https://github.com/webabcd/flutter_demo
作者 webabcd

posted @ 2023-03-22 10:18  webabcd  阅读(16)  评论(0编辑  收藏  举报