繁体   English   中英

如何在Flutter中制作具有渐变效果的轮播/滑块/图像切换器

[英]How to make carousel/slider/image switcher with fading effect in Flutter

我在网上找到了很多 slider 库,就像这里的一个: https://github.com/GeekyAnts/flutter-carousel但它们都不支持图像之间的褪色效果(幻灯片之间的图像过渡会褪色)。

I found also an example of fading animated widgets in the documentation here: https://api.flutter.dev/flutter/widgets/AnimatedCrossFade-class.html and https://api.flutter.dev/flutter/widgets/AnimatedSwitcher-类.html

我正在考虑使用文档中建议的方法制作占位符小部件并使用计时器在图像之间切换。 这是实现这一目标的最佳方法吗? 还有其他现成的库或更简单的方法吗?

您可能已经根据没有答案的时间解决了这个问题,但是今天我不得不帮助一位朋友解决了与您类似的问题并提出了相同的解决方案:使用AnimatedSwitcher + FadeTransition + Timer.periodic 在此示例中,它不是图像列表,但您可以轻松地将列表更改为List<String>并将小部件更改为Image.network而不是Icon

这是可运行的解决方案+代码: https://dartpad.dev/c1332cc136c96fa5980c3e05c7faeb4b

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM