Flutter 疑难杂症集合

一. Flutter集成uni小程序sdk

1. 手机连接电脑测试打开uni小程序没问题,打包成apk后debug编译下的apk也没问题,但就是release编译的apk包打不开小程序。
报错情景:点击后页面会闪现一下黑色的背景,然后又跳转回了点击之前的页面。
原因:开启了混淆(minifyEnabled true)但又没有把混淆规则文件放入到指定的android目录中。
解决:
打开android/app/build.gradle文件
minifyEnabled 设置成false,或者把uni小程序sdk中的proguard.cfg文件放入到指定目录中。

buildTypes {
        release {
        	// 注意点:minifyEnabled 混淆和shrinkResources移除无用资源需同时为true或false,否则可能导致编译失败!
            minifyEnabled false  //是否进行混淆
            shrinkResources false  //删除无用资源
            //指定混淆规则文件
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro', 'proguard.cfg'
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }

2. minifyEnabled 混淆和shrinkResources移除无用资源值不相同时有可能会导致编译报错。

landeMacBook-Pro:life_app lan$ flutter build apk


FAILURE: Build failed with an exception.

* Where:
Build file '/Users/lan/Desktop/flutter-demo/life_app/android/build.gradle' line: 25

* What went wrong:
A problem occurred evaluating root project 'android'.
> A problem occurred configuring project ':app'.
   > com.android.builder.errors.EvalIssueException: Removing unused resources requires unused code shrinking to be turned on. See http://d.android.com/r/tools/shrink-resources.html for more information.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

3.打开小程序后页面空白
在这里插入图片描述
解决:
主要查看项目中有条件编译的代码。
比如引入echart的条件编译代码。

// #ifdef VUE2
import * as echarts from "@/uni_modules/lime-echart/static/echarts.min";
// #endif

// #ifdef VUE3
// #ifdef MP
const echarts = require("../../uni_modules/lime-echart/static/echarts.min");
// #endif

// #ifndef MP
import * as echarts from "echarts";
import {
  BarChart,
  // 系列类型的定义后缀都为 SeriesOption
  BarSeriesOption,
  LineChart,
  LineSeriesOption,
  GaugeChart,
} from "echarts/charts";
import {
  TitleComponent,
  // 组件类型的定义后缀都为 ComponentOption
  TitleComponentOption,
  TooltipComponent,
  TooltipComponentOption,
  GridComponent,
  GridComponentOption,
  // 数据集组件
  DatasetComponent,
  DatasetComponentOption,
  // 内置数据转换器组件 (filter, sort)
  TransformComponent,
  LegendComponent,
  ToolboxComponent,
} from "echarts/components";
import { LabelLayout, UniversalTransition } from "echarts/features";
import { CanvasRenderer } from "echarts/renderers";

// 通过 ComposeOption 来组合出一个只有必须组件和图表的 Option 类型
// type ECOption = echarts.ComposeOption<
//   | BarSeriesOption
//   | LineSeriesOption
//   | TitleComponentOption
//   | TooltipComponentOption
//   | GridComponentOption
//   | DatasetComponentOption
// >;

// 注册必须的组件
echarts.use([
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  BarChart,
  LineChart,
  LabelLayout,
  UniversalTransition,
  CanvasRenderer,
  LegendComponent,
  ToolboxComponent,
  GaugeChart,
]);
// #endif
// #endif

二. 样式

1 实现磨砂玻璃效果
理想的效果
在这里插入图片描述
用BackdropFilter()方法之后父控件树也受到影响。

BackdropFilter(
 filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
 child: SizedBox(
   width: 327.w,
   height: 48.h,
   // color: Colors.white,
   child: const Row(
     children: [Text('aaa')],
   ),
 ))

在这里插入图片描述
解决方法:
可以使用ClipRect小部件将BackdropFilter小部件裁剪到其子小部件的边界。

ClipRRect(
 child: BackdropFilter(
     filter:
         ImageFilter.blur(sigmaX: 10, sigmaY: 10),
     child: SizedBox(
       width: 327.w,
       height: 48.h,
       // color: Colors.white,
       child: const Row(
         children: [Text('aaa')],
       ),
     )))
  • 6
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Flutter 应用集合是指由不同的开发者或团队开发的一系列基于 Flutter 框架构建的应用程序的集合。这些应用程序可以是各种各样的,包括但不限于社交媒体应用、电子商务应用、新闻阅读应用、音乐播放器、游戏等等。 由于 Flutter 架构的优势,应用开发者可以使用一套代码同时构建跨平台的 Android 和 iOS 应用,大大减少了开发上的工作量和时间成本。因此,Flutter 应用集合可以在不同的平台上同时提供相似或相同的用户体验,保持一致性和流畅性,无论是在 Android 还是 iOS 设备上。 Flutter 的热重载功能使得应用集合的开发更加高效,开发者可以在实时预览应用的改变,节省了重启应用的时间,加快了反馈和迭代的速度。 此外,Flutter 还提供了丰富的组件库,开发者可以利用这些组件快速构建应用的各个界面,并使用 Flutter 的 Material Design 风格或 Cupertino 风格来提供精致的用户界面。 Flutter 应用集合有助于推广 Flutter 框架,展示其强大的跨平台能力和灵活性。同时,开发者也可以通过学习和参考应用集合中的优秀作品,提高自己的开发技能,探索和应用 Flutter 的各种功能和特性。 总之,Flutter 应用集合是一系列由 Flutter 架构开发的应用程序的集合,它们通过跨平台的优势和独特的用户体验,为用户提供了多样化和高质量的应用选择,同时也促进了 Flutter 社区的发展和创新。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值