Flutter 常见错误集锦大全

1 A nullable expression can't be used as an iterator in a for-in loop

2 The property 'title' can't be unconditionally accessed because the receiver can be 'null'.

---类似的前边加个英文感叹号就可以了,表示这个变量不能为空,可以为空的话,修改为?号.

如:

book!.title

for (var book in books!)

3 Error handling 'checkPlatformOverride' custom request: method not available: ext.flutter.platformOverride

----可能是虚拟机刚删除了app,重装时有冲突,将VS Code重启,试试。

 4 should not be imported into a null safe library

这个包不支持空安全

5 Navigator operation requested with a context that does not include a Navigator.

路由问题,最好将路由放在一个无状态的组件中

Flutter Incorrect use of ParentDataWidget

组件用法有问题

6 Cannot lerp between "MaterialColor(primary value: Color(0xfff44336))" and "MaterialColor(primary value: Color(0xff2196f3))".

tween: Tween<Color>(begin: Colors.red, end: Colors.blue),

解决方式:

  • TweenAnimationBuilder<Color?>(

  • tween: ColorTween(begin: Colors.amber, end: _myColor),

7 Navigator operation requested with a context that does not include a Navigator.
无状态组件中不能有跳转Navigator

8 Android Studio (not installed))

运行 flutter config --android-studio-dir <directory> 设置你的 Android Studio 的安装目录

Failed to launch Nexus 6 API 29: Error: Emulator didn't connect within 60 seconds

The emulator process for AVD Nexus_6_API_29 was killed

碰到上面的两个错误,最快的方式感觉删除重建立一个,更快些

9 Your Flutter application is created using an older version of the Android

embedding. It's being deprecated in favor of Android embedding v2. Follow the

steps at

https://flutter.dev/go/android-project-migration

to migrate your project.

在android manifest.xml中 activity节点下增加配置

<meta-data
                android:name="flutterEmbedding"
                android:value="2" />

10 Navigator.onGenerateRoute was null, but the route named "/" was referenced.
一个原因可能是导入包的错误,应为material,有时会错误导入了cuperi...
 
11 A GlobalKey was used multiple times inside one widget's child list.

可能原因为键中值的重用

12 I/FlutterActivityDelegate( 2747): onResume setting current activity to this
E/flutter ( 2747): [ERROR:flutter/shell/common/engine.cc(147)] Could not prepare to run the isolate.
E/flutter ( 2747): [ERROR:flutter/shell/common/engine.cc(112)] Engine not prepare and launch isolate.
E/flutter ( 2747): [ERROR:flutter/shell/platform/android/android_shell_holder.cc(138)] Could not launch engine in configuration.
Syncing files to device Android SDK built for x86...

原因:构造方法无 或没有main程序入口点

const NextPage({Key? key}) : super(key: key);//添加构造方法

13  Prefer const literals as parameters of constructors on @immutable classes.dart(prefer_const_literals_to_create_immutables)

前面加上const就可以了

14 gg 13:37:10
flutter 怎么解决 软键盘弹出来的时候,把BottomNavigationBar 也顶上来了啊?朋友们

      resizeToAvoidBottomInset: false,

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

computerclass

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值