如何使图像填充具有同级文本列的行中的剩余空间?

问题描述 投票:0回答:1

我想在不使用固定高度或宽度的情况下执行此操作,这样如果用户更改显示设置中的字体大小(这将更改包含文本的第二列的高度和宽度),它仍然看起来不错。

我能做的最好的事情是以下,但是较高的缩略图会导致容器更高,并且文本下方有一个间隙,而较宽的缩略图上方和下方有白色

此外,我读到使用 Intrinsic 小部件会降低性能,并且此容器将在列表视图中重复大约 100 次,因此不确定这是一个好主意

Container(
      decoration: BoxDecoration(...),
      child: IntrinsicHeight(
        child: Row(
          children: [
            Expanded(
              child: Image(
            image: thumbnailProvider,
            fit: BoxFit.cover,
          ),
            ),
            const IntrinsicWidth(
              child: Column(children: [
                Text('hello'),
                Text('something'),
                Text('bla bla bla bla bla bla bla'),
              ]),
            ),
          ],
        ),
      ),
    );
flutter
1个回答
0
投票

尝试使用flexible或boxfit代替IntrinsicWidth或IntrinsicHeight

© www.soinside.com 2019 - 2024. All rights reserved.