Flutter Layout容器保证金 [英] Flutter Layout Container Margin

查看:75
本文介绍了Flutter Layout容器保证金的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Flutter布局有问题。

I have a problem with my Flutter Layout.

我有一个简单的容器,其左右边距为20.0
在此容器中,我还有另一个容器

I have a simple container with a Margin right and left of 20.0 Inside this container i have another container.

但是此容器仅在左侧不适合父容器。
我不知道为什么会这样。

But this container does not fit to the parent container only on the left side. I dont know why this happens.

这是我的代码:

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      backgroundColor: Colors.white,
      body: new Container(
        margin: new EdgeInsets.symmetric(horizontal: 20.0),
        child: new Container(

        )
      ),
    );
  }

问题的屏幕截图

推荐答案


您可以使用左右值:)

You can use left and right values :)



@override
Widget build(BuildContext context) {
  return Scaffold(
    backgroundColor: Colors.white,
    body: Container(
      margin: const EdgeInsets.only(left: 20.0, right: 20.0),
      child: Container(),
    ),
  );
}

这篇关于Flutter Layout容器保证金的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆