Flutter案例日程安排首页效果 Lottie动画与Shimmer实现的微光效果

案例效果: Flutter使用的版本 3.13.8,使用fvm管理版本。 加载动态地图示例,使用的是 lottie。

dart 复制代码
  Container buildMapWidget() {
    return Container(
      height: 360,
      padding: const EdgeInsets.only(top: 100, right: 40, left: 40, bottom: 50),
      decoration: BoxDecoration(color: Colors.red.shade100),
      width: double.infinity,
      child: Lottie.asset("assets/88146-event-venue.json"),
    );
  }

Lottie是一个适用于Android和iOS的移动库,它解析使用Bodymovin导出为json的Adobe After Effects动画,并在移动设备上原生渲染它们!

这个存储库是纯Dart中Lottie安卓库的非官方转换。它适用于Android、iOS、macOS、linux、windows和web。

本文章使用的 lottie 库是 2.7.0版本。

dart 复制代码
lottie: 2.7.0

加载文本特效使用的是 Shimmer

dart 复制代码
Shimmer.fromColors(
  baseColor: Colors.black,
  highlightColor: Colors.red,
  child: const Text(
    '制定一个日程安排?',
    textAlign: TextAlign.center,
    style: TextStyle(
      fontSize: 32.0,
      fontWeight: FontWeight.bold,
    ),
  ),
)

Shimmer库,用于在Flutter项目中添加微光效果的一个包,本项目使用的是3.0.0版本

dart 复制代码
shimmer: 3.0.0

加载中的占位使用的也是 Shimmer

dart 复制代码
Row(children: [
  Expanded(
    child: Shimmer.fromColors(
      baseColor: Colors.grey.shade200,
      highlightColor: Colors.grey.shade300,
      child: Container(
        width: 180,
        decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(3)),
        padding: const EdgeInsets.all(8),
      ),
    ),
  ),
  const SizedBox(width: 10),
  Expanded(
    child: Shimmer.fromColors(
      baseColor: Colors.grey.shade200,
      highlightColor: Colors.grey.shade300,
      child: Container(
        width: 100,
        decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: BorderRadius.circular(3)),
        padding: const EdgeInsets.all(8),
      ),
    ),
  )
]),

完整源码在这里

相关推荐
光影少年17 小时前
Flutter生态及学习路线
学习·flutter
傅里叶1 天前
SchedulerBinding 的三个Frame回调
前端·flutter
立方世界1 天前
Flutter技术栈深度解析:从架构设计到性能优化
flutter
前端 贾公子1 天前
《Vuejs设计与实现》第 18 章(同构渲染)(上)
android·flutter
ZFJ_张福杰1 天前
【Flutter】约束错误总结(Constraint Error 全面解析)
flutter
程序员老刘2 天前
2025年Flutter状态管理新趋势:AI友好度成为技术选型第一标准
flutter·ai编程·客户端
AGG_Chan2 天前
flutter专栏--深入了解widget原理
开发语言·javascript·flutter
墨客希2 天前
通俗易懂的理解Vue.js
vue.js·flutter
—Qeyser2 天前
Flutter bottomNavigationBar 底部导航栏
flutter