我在[IconButton,Container->Text,IconButton]中添加了包含子项的行,但第一个图标和容器之间的间距不等于容器和第二个图标之间的间距.

Row(
                       mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: <Widget>[
                        IconButton(
                            onPressed: () {},
                            icon: Icon(
                              Icons.arrow_circle_left_rounded,
                              size: 55,
                              color: AppColor.purpleColor,
                            )),
                        Container(
                          width: 80,
                          decoration: BoxDecoration(
                              color: AppColor.purpleColor,
                              shape: BoxShape.circle),
                          child: Center(
                              child: Text('33',
                                  style: GoogleFonts.lateef(
                                    textStyle: TextStyle(
                                        color: AppColor.whiteColor,
                                        fontSize: 38),
                                  ))),
                        ),
                        IconButton(
                            onPressed: () {},
                            icon: Icon(
                              Icons.arrow_circle_right_rounded,
                              size: 55,
                              color: AppColor.purpleColor,
                            )),
                      ],
                    ),

我试着用mainAxisAlignment: MainAxisAlignment.spaceEvenly, 我还试过Spacer,SizedBox.同样的问题..

我希望间距相等..

推荐答案

the problem is not with Row but with IconButton enter image description here

try 将Size值从Icon移动到IconButton

import 'package:flutter/material.dart';

void main() {
  runApp(
    const MaterialApp(
      home: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            IconButton(
                onPressed: () {},
                iconSize: 55,
                icon: const Icon(
                  Icons.arrow_circle_left_rounded,
                  color: Colors.purple,
                )),
            Container(
              width: 80,
              decoration: const BoxDecoration(
                color: Colors.purple,
                shape: BoxShape.circle,
              ),
              child: const Center(
                  child: Text(
                '33',
              )),
            ),
            IconButton(
                onPressed: () {},
                iconSize: 55,
                icon: const Icon(
                  Icons.arrow_circle_right_rounded,
                  size: 55,
                  color: Colors.purple,
                )),
          ],
        ),
      ),
    );
  }
}

enter image description here

Flutter相关问答推荐

如何增加容器高度?

如何在flutter文本字段中添加要点条目?

类型int不是可迭代动态tmdbapi类型的子类型<>

获取屏幕大小的滚动视图与动态大小?

为什么Build_Runner的输出为0?

Flutter Riverpod,将默认的BTC值改写为我的新状态

Android Studio扩展控件上未加载Google map

DART:如何判断有时可以为空的泛型类型?

如何在Flutter中将背景 colored颜色 更改为黑色?

如何在flutter中将所有单词的第一个字母大写

Flutter:如何设置 PersistentFooterButtons 背景?

如何在列表视图生成器中显示图像

如何在Flutter中动态绘制一条从A点到B点的线?

我对 Flutter Apk 有疑问

我可以在列表图块下方添加其他小部件吗

如何使这种相机叠加在Flutter 中?

如何将 chrome web 模拟器添加到 vs code

在 flutter 中自定义 agora 视频通话 UI

CircleAvatar 在 ListTile 中领先

为什么这个循环只发生一次?Flutter /dart