Describe the bug
This is a reopen of issue #2020.
Although all my dependencies are up-to-date, I still have the problem : a Blob field seems to be parsed as a GeoPoint in profile and production mode.
!!! This bug only happens with flutter build web --profile and flutter build web --production. It does not happen with flutter run !!!
I made a repository with a simple flutter app that reproduces the issue:
https://github.com/xurei/cloud_firestore_web_bug
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
void main() async {
await Firebase.initializeApp();
await FirebaseAuth.instance.signInWithEmailAndPassword(
email: '[email protected]',
password: '123456789',
);
print('Authenticated');
final FirebaseFirestore firestoreClient = FirebaseFirestore.instance;
print('Querying firestore...');
final element = await firestoreClient.collection('items').doc('123456789').get();
print('Received document');
final payload = element.data()['Payload'];
print('Payload type:');
print(payload.runtimeType);
print('(should be Blob)');
}
You need a firestore document to fetch with a Blob field.
The code should print a Blob type. With the current config, it shows GeoPoint.
The dependencies in pubspec.yaml:
dependencies:
flutter:
sdk: flutter
firebase_core: ^0.5.0+1
firebase_auth: ^0.18.1+2
cloud_firestore: ^0.14.1+3
cloud_firestore_web: ^0.2.0+4
Click To Expand
[β] Flutter (Channel beta, 1.22.1, on Linux, locale en_US.UTF-8)
[β] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[β] Chrome - develop for the web (Cannot find Chrome executable at google-chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[!] Android Studio (version 3.6)
β Flutter plugin not installed; this adds Flutter specific functionality.
β Dart plugin not installed; this adds Dart specific functionality.
[β] Android Studio (version 4.0)
[β] Connected device (1 available)
Click To Expand
Dart SDK 2.10.1
Flutter SDK 1.22.1
webflutter 1.0.0+1
dependencies:
- cloud_firestore 0.14.1+3 [flutter meta quiver firebase_core firebase_core_platform_interface cloud_firestore_platform_interface cloud_firestore_web]
- cloud_firestore_web 0.2.0+4 [flutter flutter_web_plugins firebase http_parser meta firebase_core cloud_firestore_platform_interface js]
- cupertino_icons 1.0.0
- firebase_auth 0.18.1+2 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter]
- firebase_core 0.5.0+1 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
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-nullsafety.1 [collection]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- clock 1.1.0-nullsafety.1
- cloud_firestore_platform_interface 2.1.2 [flutter meta collection firebase_core plugin_platform_interface]
- collection 1.15.0-nullsafety.3
- fake_async 1.2.0-nullsafety.1 [clock collection]
- firebase 7.3.1 [http http_parser js]
- firebase_auth_platform_interface 2.1.1 [flutter meta firebase_core plugin_platform_interface]
- firebase_auth_web 0.3.1+1 [flutter flutter_web_plugins firebase meta http_parser intl firebase_core firebase_auth_platform_interface js]
- firebase_core_platform_interface 2.0.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.0 [firebase firebase_core_platform_interface flutter flutter_web_plugins meta js]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- http 0.12.2 [http_parser path pedantic]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- intl 0.16.1 [path]
- js 0.6.2
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.3
- path 1.8.0-nullsafety.1
- pedantic 1.9.2 [meta]
- plugin_platform_interface 1.0.3 [meta]
- quiver 2.1.3 [matcher meta]
- sky_engine 0.0.99
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- stack_trace 1.10.0-nullsafety.1 [path]
- stream_channel 2.1.0-nullsafety.1 [async]
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0-nullsafety.3 [collection]
- vector_math 2.1.0-nullsafety.3
Hi @xurei.
Unable to replicate ,we have example blob data in our test database which returns the following...
.
Could this potentially be invalid data?
@dackers86 I believe you used flutter run, which works. ("Performing hot restart...")
It's not when you do a flutter build web --profile and host the built files on a server.
I updated the issue description for better clarity.
complete code sample
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
FirebaseApp app = await Firebase.initializeApp();
assert(app != null);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Material App',
theme: ThemeData.dark(),
home: Home(),
);
}
}
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
String bloby;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Firestore Example'),
),
body: Center(
child: Text(bloby ?? ''),
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
final element = await FirebaseFirestore.instance
.collection('books')
.doc('wumQplhZFiCP3K2BBTGf')
.get();
print('Received document');
final payload = element.data()['Title'];
print('Payload type:');
print(payload.runtimeType);
print('(should be Blob)');
print(bloby);
},
),
);
}
}
flutter doctor -v
[β] Flutter (Channel master, 1.24.0-2.0.pre.98, on Mac OS X 10.15.7 19H2
darwin-x64, locale en-GB)
β’ Flutter version 1.24.0-2.0.pre.98 at /Users/tahatesser/Code/flutter_master
β’ Framework revision a4ac7cce82 (7 hours ago), 2020-10-21 00:46:59 -0400
β’ Engine revision c2c74ed708
β’ Dart version 2.11.0 (build 2.11.0-240.0.dev)
[β] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
β’ Android SDK at /Users/tahatesser/Code/sdk
β’ Platform android-30, build-tools 30.0.2
β’ ANDROID_HOME = /Users/tahatesser/Code/sdk
β’ Java binary at: /Applications/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
β’ Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
β’ All Android licenses accepted.
[β] Xcode - develop for iOS and macOS (Xcode 12.1)
β’ Xcode at /Applications/Xcode.app/Contents/Developer
β’ Xcode 12.1, Build version 12A7403
β’ CocoaPods version 1.10.0.rc.1
[β] Chrome - develop for the web
β’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[β] Android Studio (version 4.1)
β’ Android Studio at /Applications/Android Studio.app/Contents
β’ Flutter plugin can be installed from:
π¨ https://plugins.jetbrains.com/plugin/9212-flutter
β’ Dart plugin can be installed from:
π¨ https://plugins.jetbrains.com/plugin/6351-dart
β’ Java version OpenJDK Runtime Environment (build
1.8.0_242-release-1644-b3-6222593)
[β] VS Code (version 1.50.1)
β’ VS Code at /Applications/Visual Studio Code.app/Contents
β’ Flutter extension version 3.15.1
[β] Connected device (6 available)
β’ RMX2001 (mobile) β’ EUYTFEUSQSRGDA6D β’
android-arm64 β’ Android 10 (API 29)
β’ Tahaβs iPhone (mobile) β’ 00008020-001059882212002E β’ ios
β’ iOS 14.1
β’ iPhone 12 Pro Max (mobile) β’ 1D3E6751-99F7-4E2E-B3DC-B3BEC4BB606F β’ ios
β’ com.apple.CoreSimulator.SimRuntime.iOS-14-1 (simulator)
β’ macOS (desktop) β’ macos β’
darwin-x64 β’ Mac OS X 10.15.7 19H2 darwin-x64
β’ Web Server (web) β’ web-server β’
web-javascript β’ Flutter Tools
β’ Chrome (web) β’ chrome β’
web-javascript β’ Google Chrome 86.0.4240.80
β’ No issues found!
@xurei @TahaTesser
Struggling to debug this one. My assumption is that a function cannot be properly read due to the minified version of the app.
Not sure how to debug this, open to suggestions on how to step through to see where the issue occurs?
@dackers86 I have no idea :-\ I never read this code.
Maybe by adding many print() between lines ?
Error: [cloud_firestore/unknown] Invalid argument (dartObject): Could not
convert: Instance of 'NativeJavaScriptObject'
Whenever I send a field of type GeoPoint to firestore for example:
final _position = GeoPoint(0,0)
store.collection('points').add({'position':_position});
This is very recent and only for web