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),
      ),
    ),
  )
]),

完整源码在这里

相关推荐
恋猫de小郭2 天前
Jetpack Compose 1.13 发布,憋了这么久终有交代了
android·前端·flutter
好的佩奇2 天前
蓝牙之设备角色与连接
android·flutter·蓝牙
SoaringHeart3 天前
Flutter最佳实践:用 flutter_html 渲染富文本
前端·flutter
恋猫de小郭4 天前
Flutter 3.50.0 Release 的第一个崩溃,修好了,还没 hotfix
android·前端·flutter
程序员老刘5 天前
跨平台开发地图 | 2026年11月
flutter·ai编程·客户端
传奇开心果编程5 天前
【Flutter踩坑排雷】第30课:异常未捕获坑|未捕获异常直接闪退,全局兜底故障处理
android·flutter·ios·移动开发·dart·ui框架·声明式ui
恋猫de小郭5 天前
Flutter Native Interop 稳定了,Platform Channel 要退场了
android·前端·flutter
好的佩奇5 天前
Dart 之可迭代对象与生成器
android·flutter·dart
恋猫de小郭6 天前
Flutter Analyzer 系列坑推进,必看,AI 时代这玩意最吃你内存
android·前端·flutter
LinXunFeng6 天前
拿竞品 App 一扫,技术栈全暴露了
android·flutter·开源