opt: 图片渲染内存

This commit is contained in:
guozhigq
2024-01-14 18:06:56 +08:00
parent db6662c980
commit 8f661337f5
5 changed files with 111 additions and 55 deletions

View File

@ -849,6 +849,14 @@ InlineSpan buildContent(
WidgetSpan(
child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints box) {
double maxHeight = box.maxWidth * 0.6; // 设置最大高度
double width = (box.maxWidth / 2).truncateToDouble();
double height = ((box.maxWidth /
2 *
pictureItem['img_height'] /
pictureItem['img_width']))
.truncateToDouble();
print('width: $width, height: $height');
return GestureDetector(
onTap: () {
showDialog(
@ -859,15 +867,28 @@ InlineSpan buildContent(
},
);
},
child: Padding(
child: Container(
padding: const EdgeInsets.only(top: 4),
child: NetworkImgLayer(
src: pictureItem['img_src'],
width: box.maxWidth / 2,
height: box.maxWidth *
0.5 *
pictureItem['img_height'] /
pictureItem['img_width'],
constraints: BoxConstraints(maxHeight: maxHeight),
width: box.maxWidth / 2,
height: height,
child: Stack(
children: [
Positioned.fill(
child: NetworkImgLayer(
src: pictureItem['img_src'],
width: box.maxWidth / 2,
height: height,
),
),
height > maxHeight
? const PBadge(
text: '长图',
right: 8,
bottom: 8,
)
: const SizedBox(),
],
),
),
);