flutter~loading效果

flutter在网络请求的时候,做了一个loading效果,结果老板说这个loading效果不好看,替换成一个动画就好了,回来就修改, 先引入flutter_easyloading: ^3.0.5

第一次默认的话代码如下

ini 复制代码
void configLoading() {
  EasyLoading.instance
    ..indicatorType = EasyLoadingIndicatorType.fadingCircle // 指定加载动画类型
    ..loadingStyle = EasyLoadingStyle.dark // 设置加载样式
    ..indicatorSize = 45.0
    ..radius = 10.0
    ..fontSize = 14
    ..maskColor = Colors.blue.withOpacity(0.5)
    ..userInteractions = true // 禁止用户交互
    ..dismissOnTap = false; // 点击时不会消失
} 

第二次很接近了但是有点不好看,多了一个黑色的背景色

ini 复制代码
void configLoading() {
  EasyLoading.instance 
    ..indicatorWidget =Lottie.asset(
      'assets/icons/loading.json',
      width: 180,
      height: 120,
      fit: BoxFit.contain,
    )
    ..loadingStyle = EasyLoadingStyle.custom // ✅ 使用自定义样式
    ..backgroundColor = Colors.transparent // ✅ 去掉黑色背景框
    ..textColor = Colors.transparent // ✅ 隐藏 loading 文字(可选)
    ..maskColor = Colors.black.withOpacity(0.3) // ✅ 设置白色遮罩层 
    ..indicatorColor = Colors.transparent
    ..indicatorSize = 0
    ..userInteractions = false
    ..dismissOnTap = false
    ..indicatorSize = 0 // ✅ 不使用内置指示器
    ..maskType = EasyLoadingMaskType.custom; // ✅ 使用自定义遮罩颜色 
}

效果图:

第三次,终于解决了,黑色的是阴影 (boxShadow),气死了

ini 复制代码
void configLoading() {
  EasyLoading.instance
    ..indicatorWidget =Lottie.asset(
      'assets/icons/loading.json',
      width: 180,
      height: 120,
      fit: BoxFit.contain,
    )
    ..loadingStyle = EasyLoadingStyle.custom // ✅ 使用自定义样式
    ..backgroundColor = Colors.transparent // ✅ 去掉黑色背景框
    ..textColor = Colors.transparent // ✅ 隐藏 loading 文字(可选)
    ..maskColor = Colors.black.withOpacity(0.3) // ✅ 设置白色遮罩层
    ..boxShadow = <BoxShadow>[]            // ✅ 去掉默认黑色阴影  重点代码(去掉icon后面黑色的背景)
    // ..contentPadding = EdgeInsets.zero     // ✅ 去掉 padding,避免默认内容包裹背景
    ..indicatorColor = Colors.transparent
    ..indicatorSize = 0
    ..userInteractions = false
    ..dismissOnTap = false
    ..indicatorSize = 0 // ✅ 不使用内置指示器
    ..maskType = EasyLoadingMaskType.custom; // ✅ 使用自定义遮罩颜色
}
相关推荐
马拉萨的春天2 小时前
block的样式有哪些?如果copy的话分别会有啥样式
flutter·性能优化·ios的block
Rattenking3 小时前
【CSS】---- 图形函数详解
笔记·学习·flutter
程序员老刘4 小时前
别再抱怨Flutter方案太多了,这个就叫生态!
flutter·客户端
黄毛火烧雪下6 小时前
(一)Flutter 插件项目demo预览图
flutter
站在远方望童年8 小时前
WSL2 中的 Flutter 开发环境配置
flutter
w_y_fan8 小时前
flutter_native_splash: ^2.4.7
android·前端·flutter
QuantumLeap丶8 小时前
《Flutter全栈开发实战指南:从零到高级》- 06 -常用布局组件
flutter·dart
大雷神1 天前
【成长纪实】Flutter中Dart 与Harmony中 ArkTS 异步编程对比:从 Future 到 Promise
flutter·harmonyos
QuantumLeap丶1 天前
《Flutter全栈开发实战指南:从零到高级》- 05 - 基础组件实战:构建登录界面
flutter·ios
黄毛火烧雪下1 天前
(四)Flutter插件之IOS插件开发
flutter·ios