簡體   English   中英

Flutter mainaxisAlignment.space甚至無法在多個flex(行和列)上使用

[英]Flutter mainaxisAlignment.spaceEvenly not working on multiple flex(Row & Column)

我正在創建類似Instagram個人資料的屏幕,但mainaxisAlignment.spaceEvenly無法正常工作。 如果該行不在任何其他行或列內,則工作正常,但在這種情況下則沒有。 我該如何解決? 請幫忙。

Container(
                margin: EdgeInsets.all(15.0),
                child: Column(
                  children: <Widget>[
                    Row(
                      children: <Widget>[
                        Container(
                          width: 100.0,
                          height: 100.0,
                          margin: EdgeInsets.only(
                            right: 10.0,
                          ),
                          decoration: new BoxDecoration(
                            shape: BoxShape.circle,
                            image: new DecorationImage(
                              fit: BoxFit.fill,
                              image: new CachedNetworkImageProvider(
                                profile.dp,
                                scale: 100.0,
                              ),
                            ),
                          ),
                        ),
                        Column(
                          children: <Widget>[
                            Row(
                              mainAxisAlignment:
                                  MainAxisAlignment.spaceEvenly,
                              children: <Widget>[
                                Column(
                                  children: <Widget>[
                                    Text(
                                      profile.postcount.toString(),
                                      style: TextStyle(
                                          fontWeight: FontWeight.bold),
                                    ),
                                    Text('posts'),
                                  ],
                                ),
                                Column(
                                  children: <Widget>[
                                    Text(
                                      profile.followers.toString(),
                                      style: TextStyle(
                                          fontWeight: FontWeight.bold),
                                    ),
                                    Text('followers'),
                                  ],
                                ),
                                Column(
                                  children: <Widget>[
                                    Text(
                                      profile.followings.toString(),
                                      style: TextStyle(
                                          fontWeight: FontWeight.bold),
                                    ),
                                    Text('following'),
                                  ],
                                ),
                              ],
                            ),
                            new RaisedButton(
                              child: Text('Edit Profile'),
                              onPressed: () {},
                            ),
                          ],
                        )
                      ],
                    )
                  ],
                )),

期望:

現實:

干得好

在此處輸入圖片說明

Widget _buildRow() {
  return Container(
    padding: const EdgeInsets.all(16),
    child: Row(
      children: <Widget>[
        CircleAvatar(
          radius: 40,
          backgroundImage: AssetImage("your_image_asset"),
        ),
        SizedBox(width: 12),
        Expanded(
          child: Column(
            mainAxisSize: MainAxisSize.min,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: <Widget>[
                  Column(
                    children: <Widget>[
                      Text("2", style: TextStyle(fontWeight: FontWeight.bold)),
                      Text("Gold", style: TextStyle(color: Colors.grey)),
                    ],
                  ),
                  Column(
                    children: <Widget>[
                      Text("22", style: TextStyle(fontWeight: FontWeight.bold)),
                      Text("Silver", style: TextStyle(color: Colors.grey)),
                    ],
                  ),
                  Column(
                    children: <Widget>[
                      Text("5464", style: TextStyle(fontWeight: FontWeight.bold)),
                      Text("Reputation", style: TextStyle(color: Colors.grey)),
                    ],
                  ),
                ],
              ),
              OutlineButton(onPressed: () {}, child: Text("CopsOnRoad (Edit Profile)")),
            ],
          ),
        ),
      ],
    ),
  );
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM