gpt4 book ai didi

flutter - FadeInImage onFocusChange 重新生成

转载 作者:行者123 更新时间:2023-12-03 16:59:25 25 4
gpt4 key购买 nike

我正在尝试使用 FadeInImage 显示整个屏幕背景图像,使用 onFocusChange 更改它们。
目前只有初始图像使用淡入淡出,然后图像才被替换。
寻求帮助:
如何使用 FadeInImage 等 onFocusChange 结果 nw 后退图像淡入..
也许用于另一个小部件。
代码:
https://gist.github.com/andraskende/4dac77fed94b9e4f131c9f644e51bc62#file-videos-dart-L80-L88

return Scaffold(
body: Container(
child: Stack(
children: [
FadeInImage.memoryNetwork(
placeholder: kTransparentImage,
image: background,
fit: BoxFit.fill,
width: double.infinity,
height: double.infinity,
fadeInDuration: Duration(milliseconds: 100),
),
......
child: ListView.builder(
itemCount: providerApp.videos.length,
scrollDirection: Axis.horizontal,
shrinkWrap: true,
itemBuilder: (BuildContext context, int index) {
return Focus(
canRequestFocus: false,
onFocusChange: (bool) {
if (bool) {
setState(() {
background = providerApp.videos[index].image;
description =
providerApp.videos[index].description;
});
}
},

最佳答案

尝试使用 唯一 key 像这样:

FadeInImage.memoryNetwork(
key: UniqueKey(),
placeholder: kTransparentImage,
image: background,
fit: BoxFit.fill,
width: double.infinity,
height: double.infinity,
fadeInDuration: Duration(milliseconds: 100),
),
在这种情况下, FadeInImage 将被重建,当调用 设置状态 方法,并且不会丢失动画

关于flutter - FadeInImage onFocusChange 重新生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63100520/

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