
Flutter踩坑集合
文章平均质量分 52
旺仔大牛
专注Android、Flutter开发,偶尔涉猎web、后端
展开
-
Flutter本地化(国际化)之App名称
Android和IOS的国际化配置,App名称的国际化、本地化原创 2023-12-21 16:16:42 · 2234 阅读 · 0 评论 -
解决IOS上架App Store后显示语言为英文的问题
IOS App在App Store中的语言显示为英文.原创 2023-12-20 17:26:58 · 2382 阅读 · 2 评论 -
解决Flutter运行报错Could not run build/ios/iphoneos/Runner.app
Could not run build/ios/iphoneos/Runner.app on Try launching Xcode and selecting "Product > Run" to fix the problem原创 2023-12-01 16:31:08 · 5561 阅读 · 0 评论 -
解决Flutter报错boxconstraints has non-normalized height/width constraints
BoxConstraints has non-normalized height constraints.The offending constraints were: BoxConstraints(0.0原创 2023-12-01 11:23:09 · 1291 阅读 · 0 评论 -
消除Flutter doctor的警告Warning: `dart` on your path resolves to xxx/bin/dart
Warning: `dart` on your path resolves to /usr/local/Cellar/dart/2.13.3/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/flutter/to/path. Consider adding /Users/flutter/to/path to the front of your path原创 2023-05-05 09:24:19 · 4679 阅读 · 1 评论 -
解决Flutter报错The method ‘File.create‘ has fewer named arguments than those of overridden method
Flutter SDK更新到3.7.9,可能会遇到file库的依赖冲突。原创 2023-04-06 14:16:01 · 2486 阅读 · 0 评论 -
Dart或Flutter中解决异常-type ‘int‘ is not a subtype of type ‘double‘
在Dart中,int和double是需要显示转换的,不然会出现异常:type 'int' is not a subtype of type 'double'原创 2022-11-25 15:34:38 · 4585 阅读 · 0 评论 -
Flutter-解决Try catch出现异常:type ‘_TypeError‘ is not a subtype of type ‘Exception‘ in type cast
在Dart或者Flutter中,捕获异常的类型是dynamic,所以可能存在类型转换异常,Unhandled Exception: type '_TypeError' is not a subtype of type 'Exception' in type cast。原创 2022-11-25 14:35:39 · 1995 阅读 · 0 评论 -
解决升级Flutter3.0后出现警告Operand of null-aware operation ‘!‘ has type ‘WidgetsBinding‘ which excludes null
更新到Flutter 3.0之后,如果用到了WidgetsBindind.instance,可能会报warning原创 2022-08-22 15:14:11 · 4020 阅读 · 2 评论 -
解决Flutter上架Google Play提示Version code 1 has already been used. Try another version code.
Flutter打包aab或者apk,versionCode必须比上一次的大,否则会提示Version code 1 has already been used. Try another version code.原创 2022-08-18 17:18:17 · 2887 阅读 · 0 评论 -
Flutter和Android中覆盖gradle中的repositories仓库地址
Android项目中都会用到三方依赖,但是从2022开始,jcenter仓库已经被废弃,如果新项目引用了一些老的三方库,库中如果还是使用jcenter解决依赖的话,就可能在运行或者编译时出现从jcenter下载依赖失败的情况。......原创 2022-08-10 17:32:06 · 9282 阅读 · 0 评论 -
解决Flutter中ThemeData.primaryColor在AppBar等组件中不生效
出现场景闲着没事,将Flutter SDK升级到了2.10.5,结果发现app所有页面的AppBar颜色全变成了默认的蓝色,在MaterialApp中设置的primaryColor颜色没有生效。MaterialApp( theme: ThemeData( primaryColor: const Color(0xFF009AA6), ),)解决方法通过Flutter的github isseus发现,从Flutter 2.5开始,Flutter团队开始慢慢移除ThemeData.prima原创 2022-04-21 17:36:03 · 5389 阅读 · 4 评论 -
IOS集成flutter_boost 3.0常见问题
no such module flutter_boost出现场景IOS集成flutter_boost后,编译运行项目,报以下错误提示 No such module ‘flutter_boost’解决方案刚开始以为是pod没有依赖成功,折腾了半天发现还是一样。最后才发现,原来是xcode打开的方式不对。刚开始是通过xcodeproj打开的ios项目,必须通过xcworkspace打开ios项目才能依赖成功!...原创 2022-04-01 11:24:43 · 5641 阅读 · 1 评论 -
解决Flutter运行IOS报错:Podfile is out of date
问题描述Flutter项目很久没有在IOS上跑过了,突然想在ios上运行一下,结果出来以下提示。Warning: Podfile is out of date This can cause issues if your application depends on plugins that do not support iOS or macOS. See https://flutter.dev/docs/development/packages-and-plugins/developing-pa原创 2021-12-23 14:04:48 · 2033 阅读 · 0 评论 -
解决flutter doctor出现Android license status unknown或cmdline-tools component is missing
文章目录问题描述解决方案问题描述使用flutter doctor检查开发环境,出现以下问题wangyangyangdeMacBook-Pro:~ wangyang$ flutter doctorDoctor summary (to see all details, run flutter doctor -v):[✓] Flutter (Channel stable, 2.2.1, on Mac OS X 10.15.7 19H2 darwin-x64, locale zh-Hans-US)原创 2021-10-13 17:00:16 · 4214 阅读 · 0 评论 -
Flutter 解决Type ‘MouseCursor‘ not found.
出现场景开发环境adodeMacBook-Pro:~ ado$ flutter --versionFlutter 2.0.3 • channel stable • https://github.com/flutter/flutter.gitFramework • revision 4d7946a68d (6 months ago) • 2021-03-18 17:24:33 -0700Engine • revision 3459eb2436Tools • Dart 2.12.2项目中需要展示原创 2021-09-19 16:23:32 · 750 阅读 · 0 评论 -
解决Invalid `Podfile` file: no implicit conversion of nil into String
Upgrading contents.xcworkspacedataRunning pod install...CocoaPods' output:↳ [!] Invalid `Podfile` file: no implicit conversion of nil into String. # from /Users/ado/my/work/flutter/testdemo4/ios/Podfile:58 # ---------------------------原创 2021-07-19 01:33:50 · 2830 阅读 · 1 评论 -
Flutter: Android SDK not found at this location,Android Studio not found at xxx
今天一个网友配置Flutter开发环境的时候,已经安装好了Android Studio,配置了Android的环境变量,然后使用flutter doctor一直提示以下错误。问题一:android sdk not found at this locationC:\users\lj> flutter doctor[√] Flutter (Channel stable, 2.0.3, on Microsoft Windows [Version 10.0.17134.165], locale en-U原创 2021-07-02 02:17:58 · 2920 阅读 · 1 评论 -
ios-解决报错-CocoaPods could not find compatible versions for pod “xxx“
出现场景使用某个三方库时,跑在IOS上报错。最近在做蓝牙相关的,需要用到蓝牙库,就找到了flutter_reactive_ble这个库。最后运行在ios上时,直接报错。[!] CocoaPods could not find compatible versions for pod "flutter_reactive_ble": In Podfile: purchases_flutter (from `.symlinks/plugins/flutter_reactive_bl原创 2021-06-28 10:06:32 · 15067 阅读 · 2 评论 -
Flutter升级更新2.0后常见报错处理
Flutter SDK更新后,经常会出现一些错误。尤其是Flutter 2.0,有些API也跟着变动了,真是牵一发而动全身啊,非常坑。以下是我更新2.0后老项目的报错解决方法。报错信息:Error: No named parameter with the name ‘resizeToAvoidBottomPadding’原因:resizeToAvoidBottomPadding在新版本的Scaffold中被resizeToAvoidBottomInset属性取代了,替换即可。Scaffold( /原创 2021-04-24 00:32:37 · 8151 阅读 · 1 评论 -
解决attempted to register plugin but it was already registered with this flutterengine
场景Flutter版本更新后,运行出现以下问题,App闪退。W/FlutterEngineCxnRegstry(10678): Attempted to register plugin (io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry$ShimRegistrarAggregate@3777b26) but it was already registered with this FlutterEngine (io.flutter.em原创 2021-04-17 02:53:59 · 2268 阅读 · 0 评论 -
解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.
场景更新Flutter到2.0后,某些代码或三方库编译出错。../../../dev_tools/flutter/.pub-cache/hosted/pub.flutter-io.cn/city_pickers-0.1.18/lib/src/cities_selector/cities_selector.dart:387:9: Error: No named parameter with the name 'resizeToAvoidBottomPadding'. resizeToAvo原创 2021-04-17 02:03:04 · 5954 阅读 · 0 评论 -
Flutter开启对空安全特性的支持
如果没有开启空安全class Item extends StatefullWidget{ final String name; User({Key? key,required this.name})}以上代码会报错,必须去掉?号才行。Error: This requires the 'non-nullable' experiment to be enabled.Try enabling this experiment by adding it to the command line when原创 2021-03-31 15:32:08 · 3017 阅读 · 2 评论 -
解决RenderUiKitView object was given an infinite size during layout.
场景有个需求,需要在Column中放个Webview。Column( children: [ Text(....), Text(....), Webview( ..... ) ])运行后控制台显示以下错误════════ Exception caught by rendering library ═════════════════════════════════════════════════════The following assertion was thrown原创 2021-03-16 21:58:08 · 2337 阅读 · 0 评论 -
Flutter集成fluwx编译出错:compileReleaseKotlin
Flutter使用fluwx后,打包android 编译报以下错误。Running Gradle task 'assembleRelease'...e: /Users/ado/my/dev_tools/flutter/.pub-cache/hosted/pub.flutter-io.cn/fluwx_no_pay-2.5.2/android/src/main/kotlin/com/jarvan/fluwx/handlers/FluwxRequestHandler.kt: (54, 52): Expect原创 2021-03-08 15:01:31 · 1497 阅读 · 0 评论 -
Flutter更改主题颜色报错:type ‘Color‘ is not a subtype of type ‘MaterialColor‘
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Futter App', debugShowCheckedModeBanner: false, theme: ThemeData( //更改主题色为白色 primarySwatch: Colors.whi原创 2021-02-06 22:30:04 · 4203 阅读 · 2 评论 -
解决CocoaPods安装卡住反应慢或失败
Building native extensions. This could take a while...current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.14.2/ext/ffi_c/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20210203-987-tfjdrx.rb extconf.rbmkmf.rb can't f原创 2021-02-04 00:06:21 · 8924 阅读 · 0 评论 -
Android Studio导入Flutter项目提示Dart SDK is not configured
原因Android Studio没有识别出电脑中的Flutter环境。解决方法打开Android Studio设置窗口。Windows版本打开方式:File ->SettingMac版本打开方式:左上角Android Studio ->Preferences然后打开Languages & Frameworks -> Flutter,在右侧的Flutter SDK path 下拉菜单中选择本地的Flutter路径,如果没有,点击右边的三个点,手动选择Flutter路原创 2021-02-02 16:51:42 · 4630 阅读 · 0 评论 -
Flutter报错:Unimplemented handling of missing static target
问题描述在Flutter开发中,当我们更改代码后,使用control+s/command+s后Flutter会自动使用Hot Reload(热重载),而不需要我们重新编译运行。但是经常会碰到一些莫名奇妙的问题。比如以下问题Unimplemented handling of missing static target同时app中也会出现同样的报错信息解决方法重新运行App,不要使用Hot Reload。使用Hot Restart....原创 2020-12-16 19:48:17 · 2292 阅读 · 0 评论 -
Flutter解决path_provider编译错误
出现场景写了个js文件,在chrome的dev tools中显示以下错误,js也没有正常运行。GET http://localhost:63342/demo/html/ad.js net::ERR_BLOCKED_BY_CLIENT解决方案将广告插件禁用,重新加载页面就不会报这个错误了。比如我用的ADGUARD...原创 2020-06-13 20:52:15 · 2481 阅读 · 2 评论 -
flutter运行报错Method not found: 'toStringDeep'.toStringDeep()
项目以前运行的好好的,突然就编译报错了,代码完全没问题。错误如下Compiler message:org-dartlang-debug:synthetic_debug_expression:1:1: Error: Method not found: ‘toStringDeep’.toStringDeep()^^^^^^^^^^^^解决方案google了一下,发现是编译问题。只需要...原创 2019-04-15 14:52:36 · 2390 阅读 · 0 评论 -
Flutter使用Scaffold报错。
错误信息E/flutter ( 7426): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: Scaffold.of() called with a context that does not contain a Scaffold.E/flutter ( 7426): No Scaffold ancestor ...原创 2019-04-09 17:07:47 · 3469 阅读 · 0 评论 -
Unable to 'pub upgrade' flutter tool. Retrying in five seconds...
原因因为Dart和Flutter都是Google开发的,所以被墙了,你懂的。解决方法为Flutter设置国内镜像就可以了。linux或mac使用vim编辑 ~/.bash_profileexport PUB_HOSTED_URL=https://pub.flutter-io.cnexport FLUTTER_STORAGE_BASE_URL=https://storage.flutt...原创 2019-04-09 09:44:56 · 5706 阅读 · 0 评论 -
Android Studio New里面没有New Flutter Project
跟着Flutter中文网的配置教程,安装好了flutter,在Android studio里面也安装了dart和flutter的插件。重启后还是在FIle->New里面没有显示New Flutter Project。反复卸载重装dart和flutter插件好几次,依然没有效果。最后在教程下面的评论里面找到解决方案。https://flutterchina.club/get-starte...原创 2019-04-04 17:49:01 · 5506 阅读 · 8 评论 -
RangeError (index): Invalid value: Valid value range is empty: 0
场景最近在学习flutter,运行时碰到了这个错误。I/flutter (25300): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════I/flutter (25300): The following RangeError was thro...原创 2019-04-04 17:22:07 · 12999 阅读 · 2 评论