Flutter 布局容器边距 [英] Flutter Layout Container Margin

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

问题描述

我的 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 布局容器边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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