我正在尝试安装 firebase_firestore flutter 插件,但出现以下错误:
flutter pub add firebase_firestore
The current Dart SDK version is 3.5.3.
Because mpolice depends on firebase_firestore any which doesn't support null safety, version solving failed.
The lower bound of "sdk: '>=1.8.0 <2.0.0-dev.infinity'" must be 2.12.0 or higher to enable null safety.
For details, see https://dart.dev/null-safety
我的 pubspec 如下:
name: mpolice
description: "Ap"
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: '>=3.3.3 <4.0.0'
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.8
intl: ^0.19.0
flutter_riverpod: ^2.5.3
firebase_core: ^3.4.0
firebase_auth: ^5.2.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^5.0.0
我无法在任何地方找到这个 sdk 范围,并且我的 pubspec 的下限已经高于 2.19.0。这个消息是从哪里来的?
我认为您想使用 firebase_core 包中的 FlutterFire 切换到 cloud_firestore。我相信 firebase_firestore 在 Dart 1 之后已被弃用,因此您需要更新到 firebase_core 和 cloud_firestore。
您可以使用检查空安全包
dart pub outdated --mode=null-safety
但我相信 firestore 和 firebase 的软件包应该是您需要的软件包。 FlutterFire 有这方面的文档,并且所有这些包都是空安全的。您还可以在任何 dart 包的版本选项卡中查看它们是否是空安全的。