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

完整源码在这里

相关推荐
吃西瓜的年年9 小时前
vue3原理思维导图
vue.js·笔记·flutter
GitLqr1 天前
从代码复用走向生态:Flutter Dart Package 实战全指南
flutter·全栈·dart
SoaringHeart1 天前
Flutter 进阶:NCanvasImageLoader 让 Canvas 也能画网络图
前端·flutter
磐链科技1 天前
钱包开发中的跨平台架构:Flutter与Rust构建高性能移动端钱包
flutter·架构·rust
iFlyCai1 天前
深入理解Flutter:StatefulWidget生命周期全解析(四)
前端·javascript·flutter
iFlyCai1 天前
Flutter setState 完全解析:原理、更新机制、误区与
flutter
恋猫de小郭1 天前
Firebase 如何让全球 Android 和 Flutter 开发者集体 Build Fail
android·前端·flutter
恋猫de小郭2 天前
Flutter 多窗口支持类型和 API 介绍
android·前端·flutter
张风捷特烈2 天前
当 AI 遇见 Flutter | 打造 500+ Widget 专属Logo
android·前端·flutter