Closed daveparks23 closed 3 years ago
Having the exact same issue. Not only when getting data, regardless if future builders, streams, or simple gets. But also with sending data using update or set, it returns the exact same error but in reverse. i.e
[cloud_firestore/unknown] Expected a value of type '((Object) => Object)?', but got one of type '(Object?) => dynamic'
Which does make sense.
I appreciate everybody's efforts on this project, thanks a lot guys!ā¤ļø
Flutter Doctor output:
Doctor summary (to see all details, run flutter doctor -v):
[ā] Flutter (Channel stable, 2.0.1, on macOS 11.2.1 20D74 darwin-x64, locale en-US)
[ā] Android toolchain - develop for Android devices
ā Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
flutter config --android-sdk
to update to that location.
[ā] Xcode - develop for iOS and macOS [ā] Chrome - develop for the web [!] Android Studio (not installed) [ā] VS Code (version 1.54.1) [ā] Connected device (1 available)
! Doctor found issues in 2 categories.
flutter pub deps output: Dart SDK 2.12.0 Flutter SDK 2.0.1 admin 1.0.0+1
dependencies:
dev dependencies:
transitive dependencies:
I don't know enough about this repo to say if this is the problem, but the docs say you should be on the beta channel, but it seems you're both on the stable channel. Also, it still recommends using the JS version 7.20.0, but you're using 8.2.10. Try switching those.
I don't know enough about this repo to say if this is the problem, but the docs say you should be on the beta channel, but it seems you're both on the stable channel. Also, it still recommends using the JS version 7.20.0, but you're using 8.2.10. Try switching those.
Thanks! I will try this but is 7.20.0 null safe? I will try beta channel also.
I thought on Wednesday they announced general availability of Null Safety for Firestore. I know how to switch to the beta channel, but where you you specify the JS version?
I don't know enough about this repo to say if this is the problem, but the docs say you should be on the beta channel, but it seems you're both on the stable channel. Also, it still recommends using the JS version 7.20.0, but you're using 8.2.10. Try switching those.
Tried on stable and beta channel, same thing. I think it's an issue with firestore ^1.0.0. When I downgrade to the last version before this, it runs fine on flutter 2.0 but without sound nullsaftey of course. Tried changing the index.html firestore js from version [7.20.0-all the way up to 8.20.10]
There error displayed while sending data is:
[cloud_firestore/unknown] Expected a value of type '((Object) => Object)?', but got one of type '(Object?) => dynamic'
using
cloud_firestore: ^1.0.0 firebase_core: ^1.0.0
@daveparks23:
is 7.20.0 null safe?
Version 7.20.0 is for the JavaScript library, which doesn't have any null-safety. It's the Dart library that turns JavaScript functions into a null-safe API. Version 1.0.0 (in the pubspec.yaml) is the version that has null-safety.
@boosey
where you you specify the JS version? There are two places you need to specify packages for web, on the Dart side and the JavaScript side.
For Dart, you use pubspec.yaml
:
cloud_firestore: "^1.0.0"
For JavaScript, you put this inweb/index.html
:
<html>
...
<body>
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/7.20.0/firebase-firestore.js"></script>
</body>
</html>
I haven't tested this with null-safety myself but this is what it says on the docs, which were updated for null-safety.
@tmldoc According to the docs:
If your app is mixing legacy and null-safe packages, use the --no-sound-null-safety flag:
$ flutter run --no-sound-null-safety
Perhaps you have other packages that are not fully null-safe? Other than that, I'd say give the doc a read-over and see if everything matches.
Thanks Levi.
Its funny. I opened the exact same bug last night, so when I saw this at the top of the list this morning, I just assumed it was mind and posted the output of the diagnostic tools. Now I see it was daveparks23's issue. :-)
That being said, one of the moderators closed my issue and pointed me to an existing version of it #5050. I actually searched Issues before I opened one and found nothing. But apparently it is a known issue.
flutter run --no-sound-null-safety
This got it working now! But the project is a fresh and clean project, with only firebase core & firestore ^1.0.0, flutter stable 2.0.1
It works on both beta and stable channels, with firebasejs/7.20.0/firebase-firestore.js
but again Running with unsound null safety
.
Would gladly wait for it to run with sound null-safety. Thanks again!
one of the moderators closed my issue and pointed me to an existing version of it #5050.
@daveparks23 So I guess this issue can be closed as a duplicate of #5050? It seems they have more info there.
Duplicate Issue https://github.com/FirebaseExtended/flutterfire/issues/5050
cloud_functions_web 4.0.1
cloud_firestore_web 1.0.1
cloud_firestore 1.0.1
firebase_core_web 1.0.1
firebase_auth_web 1.0.2
firebase_core 1.0.1
firebase_messaging_web 1.0.1
firebase_storage_web 1.0.1
The above versions have been published with this fix included. Thanks @MichaelTamm for the PR.
Bug report
Describe the bug Upgraded to Flutter 2 and null safety: When receiving data from Firebase Firestore I get the following error "Error: [cloud_firestore/unknown] Expected a value of type '((Object?) => Object)?', but got one of type '(Object) => Object?'"
Steps to reproduce the behavior: Upgrade to Flutter 2.0 and migrate to null safety pub spec.yaml
firebase sdk from index.html file
Expected behavior
Receive snapshot from Firebase Firestore with no error
Additional context
My Stream Builder code
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
``` Doctor summary (to see all details, run flutter doctor -v): [ā] Flutter (Channel stable, 2.0.1, on Mac OS X 10.15.7 19H114 darwin-x64, locale en-US) [ā] Android toolchain - develop for Android devices (Android SDK version 28.0.3) [ā] Xcode - develop for iOS and macOS [ā] Chrome - develop for the web [ā] Android Studio (version 3.5) [ā] VS Code (version 1.54.1) [ā] Connected device (1 available) ā¢ No issues found! ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` Dart SDK 2.12.0 Flutter SDK 2.0.1 analysis_data 1.0.0+1 dependencies: - auto_size_text 3.0.0-nullsafety.0 [flutter] - cloud_firestore 1.0.0 [cloud_firestore_platform_interface cloud_firestore_web firebase_core firebase_core_platform_interface flutter meta] - cupertino_icons 1.0.2 - firebase_auth 1.0.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 1.0.0 [firebase_core_platform_interface firebase_core_web flutter meta] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_spinkit 5.0.0 [flutter] - intl 0.17.0 [clock path] - percent_indicator 3.3.0-nullsafety.1 [flutter] dev dependencies: - flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data] transitive dependencies: - async 2.5.0 [collection] - boolean_selector 2.1.0 [source_span string_scanner] - characters 1.1.0 - charcode 1.2.0 - clock 1.1.0 - cloud_firestore_platform_interface 4.0.0 [collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 1.0.0 [cloud_firestore_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - collection 1.15.0 - fake_async 1.2.0 [clock collection] - firebase_auth_platform_interface 4.0.0 [firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 1.0.0 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser intl js meta] - firebase_core_platform_interface 4.0.0 [flutter meta plugin_platform_interface] - firebase_core_web 1.0.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - flutter_web_plugins 0.0.0 [flutter js characters collection meta typed_data vector_math] - http_parser 4.0.0 [charcode collection source_span string_scanner typed_data] - js 0.6.3 - matcher 0.12.10 [stack_trace] - meta 1.3.0 - path 1.8.0 - plugin_platform_interface 2.0.0 [meta] - sky_engine 0.0.99 - source_span 1.8.0 [charcode collection path term_glyph] - stack_trace 1.10.0 [path] - stream_channel 2.1.0 [async] - string_scanner 1.1.0 [charcode source_span] - term_glyph 1.2.0 - test_api 0.2.19 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher] - typed_data 1.3.0 [collection] - vector_math 2.1.0 ```