firebase 错误:未为类“ResumableMediaUploader”定义方法“NullThrowError”

9wbgstp7  于 2023-05-18  发布在  其他
关注(0)|答案(1)|浏览(187)

当我试图将我的Flutter应用程序(运行在Flutter 3. 3上)升级到Flutter 3. 10时,它一直给出错误。我升级了我所有的依赖版本,除了少数,因为它们有一些冲突。
我在我的苹果硅M1电脑上运行这个代码。
首先,我遵循this答案来修复我遇到的第一个错误:

File not found: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a

完成此操作后,该特定错误消失,但以下错误无法解决。

../../../.pub-cache/hosted/pub.dev/_discoveryapis_commons-1.0.3/lib/src/resumable_media_uploader.dart:78:44: 
Error: The method 'NullThrownError' isn't defined for the class 'ResumableMediaUploader'.

我尝试了许多解决方案,包括一些显而易见的解决方案,例如:

sudo gem uninstall cocoapods

brew install cocoapods

arch -x86_64 pod install

flutter clean
rm -Rf ios/Pods
rm ios/Podfile.lock
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.framework
rm -Rf ios/Flutter/Flutter.podspec

但是,这些都没有帮助。我发现一个论坛帖子说我应该切换到XCode 14.3 Beta,但它仍然没有解决问题。
我甚至找不到哪个依赖项导致了这个错误。那我该怎么补救呢
[编辑]我已经解决了,请看答案。

wwwo4jvm

wwwo4jvm1#

问题出在Flutter Fire UI软件包上,该软件包已被弃用。对于使用该包的任何人,我们必须为相同的任务转移到单独的包。

firebase_ui_auth
firebase_ui_firestore
firebase_ui_database

添加这些依赖项而不是使用flutterfire_ui解决了我的问题。
这里是我的依赖项的转储,包括它们的当前版本,以防有人想引用。

name: adopt_a_book
description: Adopt a Book
publish_to: 'none'
version: 2.0.2+19

environment:
  sdk: '>=3.0.0 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  # Backend
  ## Core
  intl: ^0.18.0
  shared_preferences: ^2.1.1
  is_first_run: ^1.0.0
  http: ^0.13.6
  ## Logging
  sentry_flutter: ^7.5.2
  ## firebase
  firebase_core: ^2.12.0
  firebase_auth: ^4.6.0
  firebase_storage: ^11.2.0
  cloud_firestore: ^4.7.0

  ## Notifications
  firebase_messaging: ^14.6.0
  flutter_local_notifications: ^14.0.0+2
  overlay_support: ^2.1.0
  ## bloc
  flutter_bloc: ^8.1.2
  equatable: ^2.0.5
  ## google
  google_sign_in: ^6.1.0
  googleapis: ^11.0.0
  flutter_google_places: ^0.3.0
  google_maps_flutter: ^2.2.6
  ## location
  geolocator: ^9.0.2
  geocoding: ^2.1.0
  google_geocoding: ^0.2.0
  geoflutterfire:
    git:
        url: https://github.com/gnomezgrave/GeoFlutterFire.git
        ref: 3x_null_safety # branch name
  ## misc
  open_library: ^0.1.5

  # UI related
  toggle_switch: ^2.1.0
  smooth_page_indicator: ^1.1.0
  ## icons
  cupertino_icons: ^1.0.2
  font_awesome_flutter: ^10.4.0
  material_design_icons_flutter: ^6.0.7096
  flutter_native_splash: ^2.2.19
  
  # FlutterFire
  firebase_ui_auth: ^1.4.0
  firebase_ui_firestore: ^1.5.0
  firebase_ui_database: ^1.3.0
  
  # UI elements
  image_stack: ^2.1.0
  flutter_lorem: ^2.0.0
  readmore: ^2.1.0
  flutter_rating_bar: ^4.0.0
  lottie: ^2.3.2
  image_picker: ^0.8.7+5
  image_cropper: ^4.0.1
  flutter_barcode_scanner: ^2.0.0
  currency_picker: ^2.0.16

  fluttertoast: ^8.2.1
  flutter_html: ^3.0.0-beta.1

  # Feedback
  shake: ^2.2.0
  flutter_email_sender: ^5.2.0
  feedback: ^2.6.0
  path_provider: ^2.0.15

dev_dependencies:
  # flutter_launcher_icons: ^0.10.0
  flutter_test:
    sdk: flutter
  flutter_lints: ^2.0.1

flutter_icons:
  android: "launcher_icon"
  ios: true
  image_path: "assets/icons/app_icon_background.png"

flutter:

  uses-material-design: true

  assets:
  - assets/gifs/
  - assets/images/
  - assets/books/
  - assets/banners/
  - assets/icons/
  - assets/user/
  - assets/lottie/
  - assets/logo/
  - assets/onboarding/
  - assets/time/
  - assets/copyrights/
  - assets/theme/

  fonts:
    - family: Montserrat
      fonts:
        - asset: assets/fonts/Montserrat-VariableFont_wght.ttf
        - asset: assets/fonts/Montserrat-Italic-VariableFont_wght.ttf
          style: italic
    - family: BadScript
      fonts:
        - asset: assets/fonts/BadScript-Regular.ttf
    - family: DMSerifText
      fonts:
        - asset: assets/fonts/DMSerifText-Regular.ttf
        - asset: assets/fonts/DMSerifText-Italic.ttf
          style: italic
    - family: Baskervville
      fonts:
        - asset: assets/fonts/Baskervville-Regular.ttf
        - asset: assets/fonts/Baskervville-Italic.ttf
          style: italic
    - family: OpenSans
      fonts:
        - asset: assets/fonts/OpenSans-VariableFont_wdth.ttf
        - asset: assets/fonts/OpenSans-Italic-VariableFont_wdth.ttf
          style: italic

请注意,geoflutterfire没有更新最新的Google依赖项,所以我分叉它并升级自己。

相关问题