gpt4 book ai didi

flutter - 优化带有 400 多个小框的可缩放网格

转载 作者:IT王子 更新时间:2023-10-29 07:11:19 27 4
gpt4 key购买 nike

我创建了类似带有可点击框的日历的东西,但是因为框很多,所以在 Android 上的性能很差(在 iOS 上没有这样的问题)。我正在使用以下代码来呈现整个事物:

ClipRect(
child: PhotoView.customChild(
customSize: Size(gridWidth, constraints.maxHeight),
child: GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 13,
mainAxisSpacing: 1.0,
crossAxisSpacing: 1.0,
childAspectRatio: 1),
itemCount: gridCreationHelperClass.boxWidgets.length,
physics: ClampingScrollPhysics(),
padding: const EdgeInsets.all(4.0),
itemBuilder: (BuildContext context, int index) {
return gridCreationHelperClass.boxWidgets[index];
},
),
minScale: 1.0,
//initialScale: 5.0,
backgroundDecoration: BoxDecoration(
color: Colors.transparent),
childSize: Size(gridWidth, constraints.maxHeight),
scaleChange: gridCreationHelperClass.scaleHasChanged,
)

这些 boxWidgets 可以是容器:

Container(
alignment: AlignmentDirectional.center,
color: color,
child: Text(showTextInBox ? text : "", style: TextStyle(fontSize: textInBoxSize,color: Colors.white,
fontFamily: getFontStatic(complexFont)), textAlign: TextAlign.center,)

或 SVG:

Stack(children: <Widget>[
new SvgPicture.asset(
"images/squ.svg",
color: color,

),
Text(showTextInBox ? text : "", style: TextStyle(fontSize: textInBoxSize,color: Colors.white,
fontFamily: getFontStatic(complexFont)), textAlign: TextAlign.center,)
],alignment: AlignmentDirectional.center)

此外,当添加放大文本以更轻松地查看日期时。

你知道如何让它更快吗?我正在考虑制作一个 CustomPainter,但我该如何使用它,它是否会让事情变得更快?

截图:

Main Image

Zoomed in Container

Zoomed in SVG

我正在使用这些库:

//fork of
photo_view: ^0.4.0
flutter_svg: 0.13.0+1

感谢您的帮助!

最佳答案

从未使用过 photo_view 库,但很确定您必须以某种方式缓存 View 。

查看这篇关于优化绘图的帖子...它可能有效:

How to ensure my CustomPaint widget painting is stored in the raster cache?

关于flutter - 优化带有 400 多个小框的可缩放网格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56517346/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com