图像闪烁

时间:2019-09-23 16:16:23

标签: flutter flutter-layout

在我的应用程序中,我使用了很多NetworkImages和Streambuilder,并且当我浏览该应用程序时,我的图像一直闪烁。

我不想使用FadeInImage

有什么方法可以使我的图像保持加载状态?

我尝试过:

  • 将图像提供程序替换为使用Cache的提供程序;

  • 使用AutomaticKeepAliveClientMixin

There's a sample video

示例代码:

class _RankingPageState extends State<RankingPage>
    with AutomaticKeepAliveClientMixin {
...

Container(
 width: MediaQuery.of(context).size.width,
 margin: EdgeInsets.fromLTRB(
   widget.spaceBetweenPages,
   widget.marginTopBottom,
   widget.spaceBetweenPages,
   widget.marginTopBottom,
 ),
 decoration: BoxDecoration(
   color: Colors.white,
   borderRadius:
       BorderRadius.all(Radius.circular(20)),
       boxShadow: widget.boxShadow ?? [],
       image: DecorationImage(
         fit: BoxFit.cover,
         image: AdvancedNetworkImage(
             item.picture ?? "",
             useDiskCache: true),
       ),
     ),
   ),

0 个答案:

没有答案