简体   繁体   中英

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

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM