简体   繁体   English

Flutter 容器不需要的顶部和底部填充

[英]Flutter Container unwanted top and bottom padding

I created a Container with red color as background, and another one with white color as its child.我创建了一个以红色为背景的容器,另一个以白色为子级的容器。 I think the red one will be fully covered by the white one.我认为红色的会被白色的完全覆盖。 Instead, I see two red lines on top and bottom of the container.相反,我在容器的顶部和底部看到两条红线。 Its like the Container has top and bottom padding, and I can't remove it.它就像容器有顶部和底部填充,我不能删除它。

How to remove it (the top and bottom padding?) so that the white fully cover the red one?如何删除它(顶部和底部填充?)以便白色完全覆盖红色?

The red line shows like the container has top and bottom padding红线表示容器具有顶部和底部填充

update: Just tested it on a new project, and it shows perfectly, no padding.更新:刚刚在一个新项目上进行了测试,它显示完美,没有填充。 Any idea what causing this?知道是什么原因造成的吗?

class Test extends StatefulWidget {
  Test(Object args);

  @override
  State<StatefulWidget> createState() {
    return ContainerTest();
  }
}

class ContainerTest extends State<Test>{
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Container(
        color: Colors.white,
        alignment: Alignment.center,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Text("some text"),
            ),
            Container(
              width: 200,
              height: 200,
              color: Colors.red,
              child: Container(
                color: Colors.white,
              ),
            ),
            Padding(
              padding: const EdgeInsets.all(8.0),
              child: Text("some text"),
            ),
          ],
        ),
      ),
    );
  }
}

It will be fine there is no issue you see the red lines on top and bottom due to the small size of simulator/emulator没问题,由于模拟器/模拟器体积小,您可以在顶部和底部看到红线

Please increase the size or check in the Real Device it will be fine请增加尺寸或在真实设备中检查就可以了

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用TextView在顶部和底部进行Android不需要的填充 - Android unwanted padding on top and bottom with TextView ImageView 留下不需要的顶部/底部边距/填充 - ImageView leaves unwanted top/bottom margin/padding Spinner 顶部/底部填充 - Top/Bottom Padding for Spinner Flutter 用奇怪的正底部填充和负顶部填充呈现中文文本 - 因此无法垂直居中文本 - Flutter render Chinese text with strange positive bottom padding and negative top padding - thus not possible to vertically center a text 在TextView上出现意外的顶部和底部填充? - Unexpected top and bottom padding on a TextView? CardView顶部和底部的额外填充 - Extra padding at top and bottom in CardView 删除搜索栏中的顶部和底部填充 - Remove the top and bottom padding in a SeekBar 在 flutter 中向上/向下滚动另一个底部容器后,在顶部隐藏/显示一个容器 - Hide/Show a container in the top after scrolling another bottom container up/down in flutter TextView:删除顶部和底部的间距和填充 - TextView: Remove spacing and padding on top and bottom 具有默认顶部和底部填充的 Android 应用 - Android app with default top & bottom padding
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM