【问题标题】:How to show shimmer effect on cards which is placeholder of SVG network images in flutter如何在作为 SVG 网络图像占位符的卡片上显示微光效果
【发布时间】:2022-10-15 16:40:11
【问题描述】:

我还没有看到哪个描述了我在stackoverflow中的问题的答案。

这是一些解决方法

  1. shimmer: ^latestversion 添加到您的pubspec.yml 文件中。
  2. 在您的 dart 文件中导入包 import 'package:shimmer/shimmer.dart';

【问题讨论】:

    标签: flutter dart svg card shimmer


    【解决方案1】:
    SvgPicture.network( width: 130.w,
    'https://fromnetwork.svg',
     placeholderBuilder: (BuildContext context) =>
       Container(
        child: Shimmer.fromColors(
               baseColor:Colors.grey[300]!,
               highlightColor:Colors.grey[100]!,
               child:
                    shimmerCard())),
              ),
    
    Widget shimmerCard() {
        return Container(
          color: Colors.white,
        );
      }
    

    这将使卡上的微光加载,直到从网络下载 svg 图像

    【讨论】:

      猜你喜欢
      • 2020-07-19
      • 1970-01-01
      • 2016-09-25
      • 2016-07-01
      • 2020-12-22
      • 2021-06-09
      • 2011-10-21
      • 1970-01-01
      • 2019-02-05
      相关资源
      最近更新 更多