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; // ✅ 使用自定义遮罩颜色
}
相关推荐
太子釢10 小时前
Flutter 与 Native 混合开发策略调研与方案对比
flutter
西西学代码11 小时前
Flutter---Stack
flutter
ZZZMMM.zip16 小时前
基于鸿蒙PC与鸿蒙Flutter框架构建AI本地生活服务平台
人工智能·flutter·华为·harmonyos·鸿蒙
木叶丸16 小时前
AI 编程概念与 Harness 工程实践入门
人工智能·flutter·ios
程序员老刘1 天前
腾讯混元Hy3在Flutter项目中的实战体验
flutter·ai编程
ailinghao1 天前
flutter常用的内置特性
flutter
子非鱼94271 天前
10-Flutter调用鸿蒙原生能力前置课:MethodChannel和PlatformView准备
学习·flutter·华为·harmonyos
xd1855785552 天前
鸿蒙PC时代的AI快递查询应用:基于鸿蒙Flutter框架的跨端创新实践
人工智能·flutter·华为·harmonyos·鸿蒙
ZZZMMM.zip2 天前
基于鸿蒙PC与鸿蒙Flutter框架的AI紧急求助应用开发实践
人工智能·flutter·华为·harmonyos·鸿蒙
ZZZMMM.zip2 天前
鸿蒙生态新征程:基于鸿蒙Flutter框架的AI菜谱营养应用深度解析
人工智能·flutter·华为·harmonyos·鸿蒙·鸿蒙系统