简体   繁体   English

Flutter 如何在Container中制作两列?

[英]Flutter How to make two columns in Container?

There is a Container, inside you need to make two columns.有一个容器,里面你需要做两列。 In one column there will be icons with texts, and in another there will be one icon in the center.在一列中将有带有文本的图标,在另一列中将有一个位于中心的图标。 More details on the photo enter image description here有关照片的更多详细信息,请在此处输入图像描述

I made an example of what you are trying to achieve:我举了一个你想要达到的例子:

class SO extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Container(
            height: 200,
            width: 300,
            decoration: BoxDecoration(
              color: Colors.orange,
              borderRadius: BorderRadius.circular(10),
            ),
            padding: EdgeInsets.only(left: 25),
            child: Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Row(
                      children: <Widget>[
                        Icon(
                          Icons.mail_outline,
                          color: Colors.white,
                          size: 30,
                        ),
                        Text('title'),
                      ],
                    ),
                    Row(
                      children: <Widget>[
                        Icon(
                          Icons.mail_outline,
                          color: Colors.white,
                          size: 30,
                        ),
                        Text('title'),
                      ],
                    ),
                    Row(
                      children: <Widget>[
                        Icon(
                          Icons.mail_outline,
                          color: Colors.white,
                          size: 30,
                        ),
                        Text('title'),
                      ],
                    ),
                    Row(
                      children: <Widget>[
                        Icon(
                          Icons.mail_outline,
                          color: Colors.white,
                          size: 30,
                        ),
                        Text('title'),
                      ],
                    ),
                  ],
                ),
                Spacer(),
                Container(
                  height: 60,
                  width: 60,
                  decoration: BoxDecoration(
                    shape: BoxShape.circle,
                    border: Border.all(
                      color: Colors.white,
                      width: 2,
                    ),
                  ),
                  child: Center(
                    child: Text('Photo'),
                  ),
                ),
                Spacer(),
              ],
            )),
      ),
    );
  }
}

OUTPUT: OUTPUT:

在此处输入图像描述

This is the code, which will help you attain what you want to achieve.这是代码,它将帮助您实现您想要实现的目标。 Also, I have replaced the photo with the real image, to give you a feel about how the image works.此外,我已将照片替换为真实图像,让您了解图像的工作原理。 However, it is NetworkImage(), it uses web images, if you want to use the local image, then do use AssetImage()但是,它是 NetworkImage(),它使用 web 图像,如果要使用本地图像,请使用 AssetImage()

       Container(
          height: 200.0,
          width: 350.0,
          padding: EdgeInsets.all(20.0),
          decoration: BoxDecoration(
            color: Colors.orange,
            borderRadius: BorderRadius.circular(10.0)
          ),
          child: Row(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Row(
                    children: <Widget>[
                      Icon(
                        Icons.mail_outline,
                        color: Colors.white,
                        size: 30,
                      ),
                      SizedBox(width: 10.0),
                      Text('title', style: TextStyle(fontSize: 17.0, fontWeight: FontWeight.bold)),
                    ]
                  ),
                  Row(
                    children: <Widget>[
                      Icon(
                        Icons.mail_outline,
                        color: Colors.white,
                        size: 30,
                      ),
                      SizedBox(width: 10.0),
                      Text('title', style: TextStyle(fontSize: 17.0, fontWeight: FontWeight.bold)),
                    ]
                  ),
                  Row(
                    children: <Widget>[
                      Icon(
                        Icons.mail_outline,
                        color: Colors.white,
                        size: 30,
                      ),
                      SizedBox(width: 10.0),
                      Text('title', style: TextStyle(fontSize: 17.0, fontWeight: FontWeight.bold)),
                    ]
                  )
                ]
              ),
              Expanded(
                flex: 1,
                child: Align(
                  alignment: Alignment.center,
                  child: Container(
                    height: 80.0,
                    width: 80.0,
                    decoration: BoxDecoration(
                      border: Border.all(color: Colors.white, width: 3.0),
                      borderRadius: BorderRadius.all(Radius.circular(40.0)),
                      image: DecorationImage(
                        fit: BoxFit.cover,
                        image: NetworkImage('https://image.shutterstock.com/image-photo/beautiful-pink-flower-anemones-fresh-260nw-1028135845.jpg')
                      )
                    )
                  )
                )
              )
            ]
          )
        )

RESULT结果

结果图像

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

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