flutter报错总结

1.Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

  • package:flutter_swiper
  • package:flutter_page_indicator
  • package:transformer_page_view

For solutions, see https://dart.dev/go/unsound-null-safety

摘抄自 桥豆麻袋 实测有效
解决方法:
Android Studio
run --> Edit Configurations --> Additional run args添加

--no-sound-null-safety

VS Code
在用户设置里查找 "Flutter run additional args" 并添加

--no-sound-null-safety

2.in iOS 14+, debug mode flutter apps can only be launched from flutter tooling, ides with flutter plugins or from xcode
alternatively, build in profile or release modes to enable lauching from the home screen
手机上无法单独运行flutter 项目
此处是你flutter包的路径

export PATH=/Users/hengqianjin/flutter/bin:$PATH

然后cd 到你项目路径下

cd /Users/hengqianjin/Documents/flutter-yl-finance

然后运行下面语句,就ok了

flutter run --release

不过再次用android studio 在手机上运行,就会被覆盖

3.路由跳转传参
参考子Flutter 路由命名报错 感觉他描述的不是特别详细,所以就自己再次记录了一下

请添加图片描述

The following NoSuchMethodError was thrown building Builder(dirty):
Closure call with mismatched arguments: function 'routes.'
Receiver: Closure: (dynamic, dynamic) => FindArticlePage
Tried calling: routes.(Instance of 'StatelessElement', arguments: _LinkedHashMap len:1)
Found: routes.(dynamic, dynamic) => FindArticlePage

如果你的路由跳转是这么写的:

static void openNewPageObject(BuildContext context, String routeName, Object data) {
    Navigator.pushNamed(context, routeName, arguments: data);
  }
  ///routes   (RouterManager.FIND_Article)这个只是定义的String,不要在意这些
  final routes = { 
  RouterManager.FIND_Article:(context, arguments) => FindArticlePage(arguments: arguments),
};

然后改成 arguments 放到 {} 就ok了

final routes = { 
  RouterManager.FIND_Article:(context, {arguments}) => FindArticlePage(arguments: arguments),
};

如果不是这么写的,那么不好意思,我碰到的不是你那种情况

此文章仅做学习记录使用,如有不足之处请各位大神指出,谢谢

你可能感兴趣的:(flutter报错总结)