专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

Flutter实现闪烁效果

我们在加载列表的时候,数据没请求下来之前,一般会有个加载对话框的交互,也有闪烁骨架屏交互,下面我们在flutter中实现闪烁骨架屏的交互。

1,添加依赖

shimmer: ^1.0.0

2,获取依赖包

flutter pub get

3,导入需要使用的文件中

import 'package:shimmer/shimmer.dart';

4,使用

class MyShimmer extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SizedBox(
      child: Shimmer.fromColors(
        baseColor: Colors.grey,
        highlightColor: Colors.white,
        child: Column(
          children: <Widget>[
            CoinRankingListItemSkeleton(),
            CoinRankingListItemSkeleton(),
            CoinRankingListItemSkeleton(),
            CoinRankingListItemSkeleton(),
            CoinRankingListItemSkeleton(),
            CoinRankingListItemSkeleton(),

          ],
        ),
      ),
    );
  }
}

class CoinRankingListItemSkeleton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.fromLTRB(10, 5, 10, 5),
      height: 80.0,
      child: Row(
        children: <Widget>[
          Container(width: 100.0, height: 100.0, color: Colors.grey),
          SizedBox(width: 10.0),
          Expanded(
              child: Container(
            child: Column(
              children: <Widget>[
                Container(height: 10.0, color: Colors.grey),
                SizedBox(height: 10),
                Container(height: 10.0, color: Colors.grey),
                SizedBox(height: 10),
                Container(height: 10.0, color: Colors.grey),
                SizedBox(height: 10),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    Container(width:50.0,height: 10.0, color: Colors.grey),
                    Container(width:70.0,height: 10.0, color: Colors.grey),
                    Container(width:20.0,height: 10.0, color: Colors.grey),
                  ],
                )

              ],
            ),
          ))
        ],
      ),
    );
  }
}

5,运行查看效果

130_1.png

文章永久链接:https://tech.souyunku.com/43175

未经允许不得转载:搜云库技术团队 » Flutter实现闪烁效果

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们