You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

尝试安装Firebase后Flutter新项目及旧项目均无法编译运行

解决Flutter编译报错:type 'Null' is not a subtype of type 'Procedure' in type cast

报错信息

Unhandled exception:
Crash when compiling file:///Users/Documents/FlutterDevelopment/SDKS/flutter/packages/flutter/lib/src/widgets/app.dart at character offset 71686:
../…/widgets/app.dart:1
type 'Null' is not a subtype of type 'Procedure' in type cast

解决步骤

  • 清理项目缓存并重新拉取依赖
    flutter clean
    flutter pub get
    
  • 切换Flutter至稳定版并更新SDK
    flutter channel stable
    flutter upgrade
    
  • 删除项目根目录下的.dart_tool、build文件夹后,重新尝试编译
  • 清除Firebase集成残留:移除项目中的google-services.json(Android)/GoogleService-Info.plist(iOS)文件,删除pubspec.yaml内的Firebase相关依赖,再执行flutter pub get
  • 重置VSCode Flutter插件:禁用后重新启用,或直接重启VSCode

内容的提问来源于stack exchange,提问作者user21233522

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 11:32:34