首页 > 解决方案 > MainAxisSize.SpaceEvenly 没有在小部件中提供相等的空间

问题描述

这是代码

body: Center(
          child: Column(
            children: [
              Row(
                children: [
                  CircleAvatar(
                    backgroundImage: NetworkImage(
                        'https://raw.githubusercontent.com/flutter/website/master/examples/layout/sizing/images/pic1.jpg'),
                    radius: 50,
                  ),
                  SizedBox(
                    width: 30,
                  ),
                  Container(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: [
                        Text('Post'),
                        Text('Followers'),
                        Text('Following')
                      ],
                    ),
                  )
                ],
              ),
            ],
          ),
        ),

在此处输入图像描述

标签: flutterflutter-layoutflutter-layoutbuilder

解决方案


试试下面的代码希望它对你有帮助,用过的 ListTile 小部件也可以在这里参考 ListTile 在这里参考我的答案以获得相同的设计

 ListTile(
      leading: CircleAvatar(
        backgroundImage: NetworkImage(
          'https://raw.githubusercontent.com/flutter/website/master/examples/layout/sizing/images/pic1.jpg',
        ),
        radius: 50,
      ),
      title: Container(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            Text('Post'),
            Text('Followers'),
            Text('Following'),
          ],
        ),
      ),
    ),

你的结果屏幕像->图片


推荐阅读