【问题标题】:Flutter Align the widget onto the top in ROWFlutter 将小部件对齐到 ROW 的顶部
【发布时间】:2020-11-16 14:00:05
【问题描述】:

我在 ROW 中有一个问题,一个孩子有很多项目,所以它很大,另一个孩子有更少的项目,所以它的高度很小,所以更少的项目显示在 ROW 的中心,所以我需要它来对齐ROW里面的top,你可以看看图片。

请也看看我的代码。

rowList = Row(
  mainAxisAlignment: MainAxisAlignment.spaceBetween,
  children: mainBodyList,
);

主体列表

  Container(
   width: screenWidth * 0.49,
   child: Card(
    color: Colors.white,
    child: Column(
      children: <Widget>[
        Container(
          //width: 200,
          padding: EdgeInsets.symmetric(vertical: 8, horizontal: 8),
          decoration: BoxDecoration(
            color: Colors.black12,
          ),
          child: Row(
            children: <Widget>[
              ClipOval(
                child: Material(
                  color: Colors.white,
                  child: SizedBox(
                    width: 40,
                    height: 40,
                    child:
                        /*Image.asset(
                                        'assets/icons/doc_icon.png'),*/
                        Icon(
                      Icons.playlist_add_check,
                      color: AppTheme.primaryColor,
                    ),
                  ),
                ),
              ),
              Flexible(
                child: Padding(
                  padding: const EdgeInsets.all(8.0),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: <Widget>[
                      Text(
                        _localization.localeString(name),
                        style: TextStyle(color: AppTheme.primaryColor),
                      ),
                    ],
                  ),
                ),
              ),
            ],
          ),
        ),
        Container(
          child: Column(
            children: _dynamicListWidget(list),
          ),
        ),
      ],
    ),
  ),
);

【问题讨论】:

    标签: android flutter cross-platform flutter-layout


    【解决方案1】:

    您需要将crossAxisAlignment 设置为CrossAxisAlignment.start

    Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: mainBodyList,
    );
    

    【讨论】:

    猜你喜欢
    • 2020-03-05
    • 2018-08-14
    • 1970-01-01
    • 1970-01-01
    • 2020-06-11
    • 2015-09-28
    • 2021-08-26
    • 2020-02-03
    • 2020-10-08
    相关资源
    最近更新 更多