首页 > 解决方案 > 如何在行中固定位置子小部件?扑

问题描述

我正在尝试制作评论卡。有一个问题。当评论高度增加时,我的头像和按钮不固定

在此处输入图像描述

我想固定头像图像和按钮的位置。

我怎样才能做到这一点?

import 'package:flutter/material.dart';
import '../../size_config.dart';

class CommentItem extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
      child: Row(
        children: <Widget>[
          CircleAvatar(
            radius: 25,
            child: ClipOval(
              child: SizedBox(
                height: 1000,
                width: 1000,
                child: Image.asset(
                  'assets/images/img2.jpg',
                  fit: BoxFit.cover,
                ),
              ),
            ),
          ),
          Expanded(
            child: Padding(
              padding: EdgeInsets.symmetric(horizontal: 10),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  Text('123',
                      style:
                          TextStyle(fontWeight: FontWeight.bold, fontSize: 17)),
                  SizedBox(height: 3),
                  Text(
                    '. If you want to keep these changes, it is re',
                    style: TextStyle(color: Colors.grey),
                    maxLines: 4,
                  ),
                ],
              ),
            ),
          ),
          ClipOval(
            child: Material(
              color: Colors.blue, // button color
              child: InkWell(
                splashColor: Colors.red, // inkwell color
                child: SizedBox(
                    width: SizeConfig.widthMultiplier * 8.8,
                    height: SizeConfig.heightMultiplier * 5,
                    child: Icon(
                      Icons.person_add,
                      size: SizeConfig.imageSizeMultiplier * 5.5,
                      color: Colors.white,
                    )),
                onTap: () {},
              ),
            ),
          )
        ],
      ),
    );
  }
}

看起来您的帖子主要是代码;请添加更多细节,看起来您的帖子主要是代码;请添加更多细节,看起来您的帖子主要是代码;请添加更多详细信息

标签: flutterdartflutter-layout

解决方案


您是否尝试过使用 crossAxisAlignment?

    Row(
      crossAxisAlignment: CrossAxisAlignment.start,

推荐阅读