我正在尝试从Gmail重新创建布局,但我不知道如何在布局中定位图标。
这是我想让这些图标看起来像的图片:

这是我在Flutter中已经做过的一张图片:

我希望图标之间有一个空间,我希望他们在同一高度的"McDonald波兰“。
有没有人能帮我?
代码:
import 'package:flutter/material.dart';
class GeneratedMailCouponScreen extends StatelessWidget {
  final String couponImage;
  GeneratedMailCouponScreen({Key key, @required this.couponImage}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: SafeArea(
        child: Container(
          padding: EdgeInsets.all(16.0),
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Row(
                    children: [
                      Icon(
                        Icons.arrow_back
                      )
                    ],
                  ),
                  Row(
                    children: [
                      Icon(
                        Icons.archive
                      ),
                      SizedBox(width: 5.0),
                      Icon(
                        Icons.delete
                      ),
                      SizedBox(width: 5.0),
                      Icon(
                        Icons.mail
                      ),
                      SizedBox(width: 5.0),
                      Icon(
                        Icons.more_vert
                      )
                    ],
                  )
                ],
              ),
              SizedBox(height: 16.0),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Row(
                    children: [
                      Text('Voucher', style: TextStyle(color: Colors.black, fontSize: 18.0)),
                      SizedBox(width: 8.0),
                      Container(
                        color: Colors.grey[200],
                        child: Padding(
                          padding: EdgeInsets.fromLTRB(4, 2, 4, 2),
                          child: Text('Odebrane', style: TextStyle(color: Colors.black, fontSize: 12.0),),
                        ),
                      )
                    ],
                  ),
                  Row(
                    children: [
                      Icon(
                        Icons.star_border
                      )
                    ],
                  )
                ],
              ),
              SizedBox(height: 16.0),
              Row(
                children: [
                  Container(
                    height: 45.0,
                    width: 45.0,
                    decoration: BoxDecoration(
                      color: Colors.blue[100],
                      shape: BoxShape.circle
                    ),
                    child: Center(
                      child: Text('M', style: TextStyle(fontSize: 20.0),),
                    )
                  ),
                  Row(
                    children: [
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          Row(
                            children: [
                              Text('McDonalds Poland', style: TextStyle(color: Colors.black)),
                              SizedBox(width: 8.0),
                              Text('Wczoraj', style: TextStyle(color: Colors.grey))
                            ],
                          ),
                          Row(
                            children: [
                              Text('do mnie', style: TextStyle(color: Colors.grey)),
                              Icon(
                                Icons.expand_more
                              )
                            ],
                          )
                        ],
                      ),
                      Row(
                        children: [
                          Icon(
                            Icons.reply
                          ),
                          Icon(
                            Icons.more_vert
                          )
                        ],
                      )
                    ],
                  )
                ],
              )
            ],
          ),
        ),
      ),
    );
  }
}发布于 2019-09-26 19:43:24
我已经对你的代码做了一些修改,请检查它是否适用于你

import 'package:flutter/material.dart';
class GeneratedMailCouponScreen extends StatelessWidget {
  final String couponImage;
      GeneratedMailCouponScreen({Key key, @required this.couponImage})
  : super(key: key);
  @override
  Widget build(BuildContext context) {
return Scaffold(
  backgroundColor: Colors.white,
  body: SafeArea(
    child: Container(
      padding: EdgeInsets.all(16.0),
      child: Column(
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(
                children: [Icon(Icons.arrow_back)],
              ),
              Row(
                children: [
                  Icon(Icons.archive),
                  SizedBox(width: 5.0),
                  Icon(Icons.delete),
                  SizedBox(width: 5.0),
                  Icon(Icons.mail),
                  SizedBox(width: 5.0),
                  Icon(Icons.more_vert)
                ],
              )
            ],
          ),
          SizedBox(height: 16.0),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(
                children: [
                  Text(
                    'Voucher',
                    style: TextStyle(color: Colors.black, fontSize: 18.0),
                  ),
                  SizedBox(width: 8.0),
                  Container(
                    color: Colors.grey[200],
                    child: Padding(
                      padding: EdgeInsets.fromLTRB(4, 2, 4, 2),
                      child: Text(
                        'Odebrane',
                        style:
                            TextStyle(color: Colors.black, fontSize: 12.0),
                      ),
                    ),
                  )
                ],
              ),
              Row(
                children: [Icon(Icons.star_border)],
              )
            ],
          ),
          SizedBox(height: 16.0),
          Row(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Container(
                height: 45.0,
                width: 45.0,
                decoration: BoxDecoration(
                    color: Colors.blue[100], shape: BoxShape.circle),
                child: Center(
                  child: Text(
                    'M',
                    style: TextStyle(fontSize: 20.0),
                  ),
                ),
              ),
              SizedBox(width: 10),
              Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    children: [
                      Text(
                        'McDonalds Poland',
                        style: TextStyle(color: Colors.black),
                      ),
                      SizedBox(width: 8.0),
                      Text(
                        'Wczoraj',
                        style: TextStyle(color: Colors.grey),
                      )
                    ],
                  ),
                  Row(
                    children: [
                      Text('do mnie',
                          style: TextStyle(color: Colors.grey)),
                      Icon(Icons.expand_more)
                    ],
                  )
                ],
              ),
              Spacer(flex: 1,),
              Row(
                children: [Icon(Icons.reply), Icon(Icons.more_vert)],
              )
            ],
          )
        ],
      ),
        ),
      ),
    );
  }
}发布于 2019-09-26 21:16:23
我做了一些改动。现在,这些图标的高度与文本高度相同,我希望对您有效
 @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: SafeArea(
        child: Container(
          padding: EdgeInsets.all(16.0),
          child: Column(
            children: [
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Row(
                    children: [Icon(Icons.arrow_back)],
                  ),
                  Row(
                    children: [
                      Icon(Icons.archive),
                      SizedBox(width: 5.0),
                      Icon(Icons.delete),
                      SizedBox(width: 5.0),
                      Icon(Icons.mail),
                      SizedBox(width: 5.0),
                      Icon(Icons.more_vert)
                    ],
                  )
                ],
              ),
              SizedBox(height: 16.0),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Row(
                    children: [
                      Text('Voucher',
                          style:
                              TextStyle(color: Colors.black, fontSize: 18.0)),
                      SizedBox(width: 8.0),
                      Container(
                        color: Colors.grey[200],
                        child: Padding(
                          padding: EdgeInsets.fromLTRB(4, 2, 4, 2),
                          child: Text(
                            'Odebrane',
                            style:
                                TextStyle(color: Colors.black, fontSize: 12.0),
                          ),
                        ),
                      )
                    ],
                  ),
                  Row(
                    children: [Icon(Icons.star_border)],
                  )
                ],
              ),
              SizedBox(height: 16.0),
              Container(
                child: Row(
                  mainAxisSize: MainAxisSize.max,
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: <Widget>[
                    Container(
                        height: 45.0,
                        width: 45.0,
                        decoration: BoxDecoration(
                            color: Colors.blue[100], shape: BoxShape.circle),
                        child: Center(
                          child: Text(
                            'M',
                            style: TextStyle(fontSize: 20.0),
                          ),
                        )),
                    SizedBox(
                      width: 16,
                    ),
                    Expanded(
                      child: Container(
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: <Widget>[
                            Container(
                              child: Row(
                                mainAxisAlignment:
                                    MainAxisAlignment.spaceBetween,
                                children: <Widget>[
                                  Container(
                                    child: Row(
                                      children: <Widget>[
                                        Text('McDonalds Poland',
                                            style:
                                                TextStyle(color: Colors.black)),
                                        SizedBox(width: 8.0),
                                        Text('Wczoraj',
                                            style:
                                                TextStyle(color: Colors.grey)),
                                      ],
                                    ),
                                  ),
                                  Container(
                                    child: Row(
                                      children: <Widget>[
                                        Icon(Icons.reply),
                                        Icon(Icons.more_vert)
                                      ],
                                    ),
                                  )
                                ],
                              ),
                            ),
                            Container(
                              child: Row(
                                children: [
                                  Text('do mnie',
                                      style: TextStyle(color: Colors.grey)),
                                  Icon(Icons.expand_more)
                                ],
                              ),
                            )
                          ],
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }发布于 2019-09-27 04:14:19
这是工作!你必须把'M‘Container放在Row里面,把图标放在Container里面
return Scaffold(
      body: Container(
          padding: EdgeInsets.only(top: 50),
          child: new Column(
              mainAxisAlignment: MainAxisAlignment.start,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: <Widget>[
                Row(
                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.end,
                  children: [                    
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      crossAxisAlignment: CrossAxisAlignment.end,
                      children: [
                        Container(
                        height: 45.0,
                        width: 45.0,
                        decoration: BoxDecoration(
                            color: Colors.blue[100], shape: BoxShape.circle),
                        child: Center(
                          child: Text(
                            'M',
                            style: TextStyle(fontSize: 20.0),
                          ),
                        )),
                        Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Row(
                              children: [
                                Text('McDonalds Poland',
                                    style: TextStyle(color: Colors.black)),
                                SizedBox(width: 8.0),
                                Text('Wczoraj',
                                    style: TextStyle(color: Colors.grey))
                              ],
                            ),
                            Row(
                              children: [
                                Text('do mnie',
                                    style: TextStyle(color: Colors.grey)),
                                Icon(Icons.expand_more)
                              ],
                            )
                          ],
                        ),                        
                      ],
                    ),
                    Container(
                          padding: EdgeInsets.only(top: 50),
                          child: Row(
                            children: [
                              Icon(Icons.reply),
                              Icon(Icons.more_vert)
                            ],
                          ),
                        )
                  ],
                )
              ])),
    );

https://stackoverflow.com/questions/58115653
复制相似问题