如何在没有声音的情况下构建APK无效 [英] How to build APK with no sound null safety

查看:62
本文介绍了如何在没有声音的情况下构建APK无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以通过传递标志-no-sound-null-safety --release 在手机上以发布模式运行应用程序,但是都没有 flutter build apk --enable-experiment = non-nullable 也不 build apk --no-sound-null-safety 也没有 flutter build apk --enable-experiment = non-nullable --no-sound-null-safety 可以工作

I can run an app in release mode on my phone with passing flag --no-sound-null-safety --release, but neither flutter build apk --enable-experiment=non-nullable nor flutter build apk --no-sound-null-safety nor flutter build apk --enable-experiment=non-nullable --no-sound-null-safety will work

推荐答案

仅需在 main.dart中的所有导入之前使用附加注释//@ dart = 2.9 代码>,因此它可以在没有任何标志的情况下运行

It was only necessary to use additional comment // @dart=2.9 before all imports in main.dart so it could run without any flags

所以 main.dart 应该看起来像这样:

So main.dart should look like this:

// @dart=2.9
import 'package:flutter/gestures.dart';
import 'package:flutter/widgets.dart';
import '../init.dart';

Future<void> main() async {
  GestureBinding.instance?.resamplingEnabled = true;
  WidgetsFlutterBinding.ensureInitialized();
  await init();
  runApp(MyApp());
}

任何其他 .dart 文件不需要注释它们

Any other .dart files don't require annotating them

P.S.确保您已更新 pubspec.yaml 以使用Dart 2.12:

P.S. make sure you updated pubspec.yaml for using Dart 2.12:

environment:
  sdk: '>=2.12.0-0.0 <3.0.0'

这篇关于如何在没有声音的情况下构建APK无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆