Skip to content

Commit c2771a4

Browse files
authored
fix(database, web): change the interop to fix an issue with startAt/endAt/limitTo when compilating with dart2js in release mode (#9251)
* fix(database, web): change the interop to fix an issue with startAt/endAt/limitTo when compilating with dart2js in release mode * fix(database, web): change the interop to fix an issue with startAt/endAt/limitTo when compilating with dart2js in release mode
1 parent 35cce5b commit c2771a4

File tree

2 files changed

+29
-41
lines changed

2 files changed

+29
-41
lines changed

packages/firebase_database/firebase_database_web/lib/src/interop/database.dart

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
import 'dart:async';
99
import 'dart:js';
10+
1011
import 'package:firebase_core_web/firebase_core_web_interop.dart'
1112
as core_interop;
13+
import 'package:firebase_core_web/firebase_core_web_interop.dart'
14+
hide jsify, dartify, callMethod;
1215
import 'package:firebase_database_platform_interface/firebase_database_platform_interface.dart';
1316
import 'package:firebase_database_web/firebase_database_web.dart'
1417
show convertFirebaseDatabaseException;
15-
import 'package:firebase_core_web/firebase_core_web_interop.dart'
16-
hide jsify, dartify, callMethod;
1718
import 'package:flutter/widgets.dart';
1819
import 'package:js/js_util.dart';
1920

@@ -455,12 +456,12 @@ class Query<T extends database_interop.QueryJsImpl> extends JsObjectWrapper<T> {
455456
dynamic toJson() => dartify(jsObject.toJSON());
456457

457458
S? _createQueryConstraint<S>(
458-
Function method, List<dynamic>? /*list of primitive value */ args) {
459+
Object method, List<dynamic>? /*list of primitive value */ args) {
459460
if (args == null) {
460461
throw ArgumentError('Please provide "args" parameter.');
461462
}
462463
var params = args.map(jsify).toList();
463-
return callMethod(method, 'apply', jsify([null, params]));
464+
return callMethod(method, 'apply', [null, jsify(params)]);
464465
}
465466
}
466467

packages/firebase_database/firebase_database_web/lib/src/interop/database_interop.dart

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ library firebase.database_interop;
1010

1111
import 'package:firebase_core_web/firebase_core_web_interop.dart'
1212
show PromiseJsImpl, Func1, AppJsImpl;
13-
1413
import 'package:js/js.dart';
1514

1615
part 'data_snapshot_interop.dart';
17-
1816
part 'query_interop.dart';
19-
2017
part 'reference_interop.dart';
2118

2219
@JS()
@@ -30,34 +27,6 @@ external void connectDatabaseEmulator(
3027
external void enableLogging(
3128
[/* Func message || bool enabled */ loggerOrEnabled, bool persistent]);
3229

33-
@JS()
34-
external QueryConstraintJsImpl endAt(
35-
dynamic /* number | string | boolean | null */ value,
36-
[String key]);
37-
38-
@JS()
39-
external QueryConstraintJsImpl endBefore(
40-
dynamic /* number | string | boolean | null */ value,
41-
[String key]);
42-
43-
@JS()
44-
external QueryConstraintJsImpl equalTo(
45-
dynamic /* number | string | boolean | null */ value,
46-
String key,
47-
);
48-
49-
@JS()
50-
external QueryConstraintJsImpl startAfter(
51-
dynamic /* number | string | boolean | null */ value,
52-
String key,
53-
);
54-
55-
@JS()
56-
external QueryConstraintJsImpl startAt(
57-
dynamic /* number | string | boolean | null */ value,
58-
String key,
59-
);
60-
6130
@JS()
6231
external PromiseJsImpl<void> update(
6332
ReferenceJsImpl ref,
@@ -86,12 +55,6 @@ external void goOnline(DatabaseJsImpl database);
8655
@JS()
8756
external dynamic increment(int delta);
8857

89-
@JS()
90-
external QueryConstraintJsImpl limitToFirst(int limit);
91-
92-
@JS()
93-
external QueryConstraintJsImpl limitToLast(int limit);
94-
9558
@JS()
9659
external void off([
9760
QueryJsImpl query,
@@ -286,3 +249,27 @@ abstract class FirebaseError {
286249
/// Not part of the core JS API, but occasionally exposed in error objects.
287250
external Object get serverResponse;
288251
}
252+
253+
// We type those 7 functions as Object to avoid an issue with dart2js compilation
254+
// in release mode
255+
// Discussed internally with dart2js team
256+
@JS()
257+
external Object get endAt;
258+
259+
@JS()
260+
external Object get endBefore;
261+
262+
@JS()
263+
external Object get equalTo;
264+
265+
@JS()
266+
external Object get startAfter;
267+
268+
@JS()
269+
external Object get startAt;
270+
271+
@JS()
272+
external Object get limitToFirst;
273+
274+
@JS()
275+
external Object get limitToLast;

0 commit comments

Comments
 (0)