Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit d4fd64f

Browse files
author
Chris Yang
authored
[Cloud_firestore]add type params for invokeMethod calls. (#1414)
Bump min flutter version to 1.2.0. Add template type parameter for invokeMethod calls. Updated invokeMethod and invokeMethod to using invokeListMethod and invokeMapMethod if any. flutter/flutter#26431
1 parent 5fba490 commit d4fd64f

File tree

7 files changed

+36
-89
lines changed

7 files changed

+36
-89
lines changed

packages/cloud_firestore/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.9.7+2
2+
3+
* Bump the minimum Flutter version to 1.2.0.
4+
* Add template type parameter to `invokeMethod` calls.
5+
16
## 0.9.7+1
27

38
* Update README with example of getting a document.

packages/cloud_firestore/lib/src/document_reference.dart

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ class DocumentReference {
4040
/// If [merge] is true, the provided data will be merged into an
4141
/// existing document instead of overwriting.
4242
Future<void> setData(Map<String, dynamic> data, {bool merge = false}) {
43-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
44-
// https://github.com/flutter/flutter/issues/26431
45-
// ignore: strong_mode_implicit_dynamic_method
46-
return Firestore.channel.invokeMethod(
43+
return Firestore.channel.invokeMethod<void>(
4744
'DocumentReference#setData',
4845
<String, dynamic>{
4946
'app': firestore.app.name,
@@ -61,10 +58,7 @@ class DocumentReference {
6158
///
6259
/// If no document exists yet, the update will fail.
6360
Future<void> updateData(Map<String, dynamic> data) {
64-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
65-
// https://github.com/flutter/flutter/issues/26431
66-
// ignore: strong_mode_implicit_dynamic_method
67-
return Firestore.channel.invokeMethod(
61+
return Firestore.channel.invokeMethod<void>(
6862
'DocumentReference#updateData',
6963
<String, dynamic>{
7064
'app': firestore.app.name,
@@ -78,10 +72,8 @@ class DocumentReference {
7872
///
7973
/// If no document exists, the read will return null.
8074
Future<DocumentSnapshot> get() async {
81-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
82-
// https://github.com/flutter/flutter/issues/26431
83-
// ignore: strong_mode_implicit_dynamic_method
84-
final Map<dynamic, dynamic> data = await Firestore.channel.invokeMethod(
75+
final Map<String, dynamic> data =
76+
await Firestore.channel.invokeMapMethod<String, dynamic>(
8577
'DocumentReference#get',
8678
<String, dynamic>{'app': firestore.app.name, 'path': path},
8779
);
@@ -94,10 +86,7 @@ class DocumentReference {
9486

9587
/// Deletes the document referred to by this [DocumentReference].
9688
Future<void> delete() {
97-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
98-
// https://github.com/flutter/flutter/issues/26431
99-
// ignore: strong_mode_implicit_dynamic_method
100-
return Firestore.channel.invokeMethod(
89+
return Firestore.channel.invokeMethod<void>(
10190
'DocumentReference#delete',
10291
<String, dynamic>{'app': firestore.app.name, 'path': path},
10392
);
@@ -120,10 +109,7 @@ class DocumentReference {
120109
StreamController<DocumentSnapshot> controller; // ignore: close_sinks
121110
controller = StreamController<DocumentSnapshot>.broadcast(
122111
onListen: () {
123-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
124-
// https://github.com/flutter/flutter/issues/26431
125-
// ignore: strong_mode_implicit_dynamic_method
126-
_handle = Firestore.channel.invokeMethod(
112+
_handle = Firestore.channel.invokeMethod<int>(
127113
'Query#addDocumentListener',
128114
<String, dynamic>{
129115
'app': firestore.app.name,
@@ -136,10 +122,7 @@ class DocumentReference {
136122
},
137123
onCancel: () {
138124
_handle.then((int handle) async {
139-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
140-
// https://github.com/flutter/flutter/issues/26431
141-
// ignore: strong_mode_implicit_dynamic_method
142-
await Firestore.channel.invokeMethod(
125+
await Firestore.channel.invokeMethod<void>(
143126
'Query#removeListener',
144127
<String, dynamic>{'handle': handle},
145128
);

packages/cloud_firestore/lib/src/firestore.dart

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,21 @@ class Firestore {
110110
'Transaction timeout must be more than 0 milliseconds');
111111
final int transactionId = _transactionHandlerId++;
112112
_transactionHandlers[transactionId] = transactionHandler;
113-
final Map<dynamic, dynamic> result = await channel
114-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
115-
// https://github.com/flutter/flutter/issues/26431
116-
// ignore: strong_mode_implicit_dynamic_method
117-
.invokeMethod('Firestore#runTransaction', <String, dynamic>{
113+
final Map<String, dynamic> result = await channel
114+
.invokeMapMethod<String, dynamic>(
115+
'Firestore#runTransaction', <String, dynamic>{
118116
'app': app.name,
119117
'transactionId': transactionId,
120118
'transactionTimeout': timeout.inMilliseconds
121119
});
122-
return result?.cast<String, dynamic>() ?? <String, dynamic>{};
120+
return result ?? <String, dynamic>{};
123121
}
124122

125123
@deprecated
126124
Future<void> enablePersistence(bool enable) async {
127125
assert(enable != null);
128-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
129-
// https://github.com/flutter/flutter/issues/26431
130-
// ignore: strong_mode_implicit_dynamic_method
131-
await channel.invokeMethod('Firestore#enablePersistence', <String, dynamic>{
126+
await channel
127+
.invokeMethod<void>('Firestore#enablePersistence', <String, dynamic>{
132128
'app': app.name,
133129
'enable': enable,
134130
});
@@ -139,10 +135,7 @@ class Firestore {
139135
String host,
140136
bool sslEnabled,
141137
bool timestampsInSnapshotsEnabled}) async {
142-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
143-
// https://github.com/flutter/flutter/issues/26431
144-
// ignore: strong_mode_implicit_dynamic_method
145-
await channel.invokeMethod('Firestore#settings', <String, dynamic>{
138+
await channel.invokeMethod<void>('Firestore#settings', <String, dynamic>{
146139
'app': app.name,
147140
'persistenceEnabled': persistenceEnabled,
148141
'host': host,

packages/cloud_firestore/lib/src/query.dart

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,7 @@ class Query {
5353
StreamController<QuerySnapshot> controller; // ignore: close_sinks
5454
controller = StreamController<QuerySnapshot>.broadcast(
5555
onListen: () {
56-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
57-
// https://github.com/flutter/flutter/issues/26431
58-
// ignore: strong_mode_implicit_dynamic_method
59-
_handle = Firestore.channel.invokeMethod(
56+
_handle = Firestore.channel.invokeMethod<int>(
6057
'Query#addSnapshotListener',
6158
<String, dynamic>{
6259
'app': firestore.app.name,
@@ -70,10 +67,7 @@ class Query {
7067
},
7168
onCancel: () {
7269
_handle.then((int handle) async {
73-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
74-
// https://github.com/flutter/flutter/issues/26431
75-
// ignore: strong_mode_implicit_dynamic_method
76-
await Firestore.channel.invokeMethod(
70+
await Firestore.channel.invokeMethod<void>(
7771
'Query#removeListener',
7872
<String, dynamic>{'handle': handle},
7973
);
@@ -86,10 +80,8 @@ class Query {
8680

8781
/// Fetch the documents for this query
8882
Future<QuerySnapshot> getDocuments() async {
89-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
90-
// https://github.com/flutter/flutter/issues/26431
91-
// ignore: strong_mode_implicit_dynamic_method
92-
final Map<dynamic, dynamic> data = await Firestore.channel.invokeMethod(
83+
final Map<String, dynamic> data =
84+
await Firestore.channel.invokeMapMethod<String, dynamic>(
9385
'Query#getDocuments',
9486
<String, dynamic>{
9587
'app': firestore.app.name,

packages/cloud_firestore/lib/src/transaction.dart

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ class Transaction {
1414
Firestore _firestore;
1515

1616
Future<DocumentSnapshot> get(DocumentReference documentReference) async {
17-
final dynamic result = await Firestore.channel
18-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
19-
// https://github.com/flutter/flutter/issues/26431
20-
// ignore: strong_mode_implicit_dynamic_method
21-
.invokeMethod('Transaction#get', <String, dynamic>{
17+
final Map<String, dynamic> result = await Firestore.channel
18+
.invokeMapMethod<String, dynamic>('Transaction#get', <String, dynamic>{
2219
'app': _firestore.app.name,
2320
'transactionId': _transactionId,
2421
'path': documentReference.path,
@@ -33,10 +30,7 @@ class Transaction {
3330

3431
Future<void> delete(DocumentReference documentReference) async {
3532
return Firestore.channel
36-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
37-
// https://github.com/flutter/flutter/issues/26431
38-
// ignore: strong_mode_implicit_dynamic_method
39-
.invokeMethod('Transaction#delete', <String, dynamic>{
33+
.invokeMethod<void>('Transaction#delete', <String, dynamic>{
4034
'app': _firestore.app.name,
4135
'transactionId': _transactionId,
4236
'path': documentReference.path,
@@ -46,10 +40,7 @@ class Transaction {
4640
Future<void> update(
4741
DocumentReference documentReference, Map<String, dynamic> data) async {
4842
return Firestore.channel
49-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
50-
// https://github.com/flutter/flutter/issues/26431
51-
// ignore: strong_mode_implicit_dynamic_method
52-
.invokeMethod('Transaction#update', <String, dynamic>{
43+
.invokeMethod<void>('Transaction#update', <String, dynamic>{
5344
'app': _firestore.app.name,
5445
'transactionId': _transactionId,
5546
'path': documentReference.path,
@@ -59,10 +50,8 @@ class Transaction {
5950

6051
Future<void> set(
6152
DocumentReference documentReference, Map<String, dynamic> data) async {
62-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
63-
// https://github.com/flutter/flutter/issues/26431
64-
// ignore: strong_mode_implicit_dynamic_method
65-
return Firestore.channel.invokeMethod('Transaction#set', <String, dynamic>{
53+
return Firestore.channel
54+
.invokeMethod<void>('Transaction#set', <String, dynamic>{
6655
'app': _firestore.app.name,
6756
'transactionId': _transactionId,
6857
'path': documentReference.path,

packages/cloud_firestore/lib/src/write_batch.dart

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ part of cloud_firestore;
1212
/// nor can it be committed again.
1313
class WriteBatch {
1414
WriteBatch._(this._firestore)
15-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
16-
// https://github.com/flutter/flutter/issues/26431
17-
// ignore: strong_mode_implicit_dynamic_method
18-
: _handle = Firestore.channel.invokeMethod(
15+
: _handle = Firestore.channel.invokeMethod<dynamic>(
1916
'WriteBatch#create', <String, dynamic>{'app': _firestore.app.name});
2017

2118
final Firestore _firestore;
@@ -32,10 +29,7 @@ class WriteBatch {
3229
if (!_committed) {
3330
_committed = true;
3431
await Future.wait<dynamic>(_actions);
35-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
36-
// https://github.com/flutter/flutter/issues/26431
37-
// ignore: strong_mode_implicit_dynamic_method
38-
await Firestore.channel.invokeMethod(
32+
await Firestore.channel.invokeMethod<void>(
3933
'WriteBatch#commit', <String, dynamic>{'handle': await _handle});
4034
} else {
4135
throw StateError("This batch has already been committed.");
@@ -47,10 +41,7 @@ class WriteBatch {
4741
if (!_committed) {
4842
_handle.then((dynamic handle) {
4943
_actions.add(
50-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
51-
// https://github.com/flutter/flutter/issues/26431
52-
// ignore: strong_mode_implicit_dynamic_method
53-
Firestore.channel.invokeMethod(
44+
Firestore.channel.invokeMethod<void>(
5445
'WriteBatch#delete',
5546
<String, dynamic>{
5647
'app': _firestore.app.name,
@@ -77,10 +68,7 @@ class WriteBatch {
7768
if (!_committed) {
7869
_handle.then((dynamic handle) {
7970
_actions.add(
80-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
81-
// https://github.com/flutter/flutter/issues/26431
82-
// ignore: strong_mode_implicit_dynamic_method
83-
Firestore.channel.invokeMethod(
71+
Firestore.channel.invokeMethod<void>(
8472
'WriteBatch#setData',
8573
<String, dynamic>{
8674
'app': _firestore.app.name,
@@ -105,10 +93,7 @@ class WriteBatch {
10593
if (!_committed) {
10694
_handle.then((dynamic handle) {
10795
_actions.add(
108-
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
109-
// https://github.com/flutter/flutter/issues/26431
110-
// ignore: strong_mode_implicit_dynamic_method
111-
Firestore.channel.invokeMethod(
96+
Firestore.channel.invokeMethod<void>(
11297
'WriteBatch#updateData',
11398
<String, dynamic>{
11499
'app': _firestore.app.name,

packages/cloud_firestore/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for Cloud Firestore, a cloud-hosted, noSQL database
33
live synchronization and offline support on Android and iOS.
44
author: Flutter Team <flutter-dev@googlegroups.com>
55
homepage: https://github.com/flutter/plugins/tree/master/packages/cloud_firestore
6-
version: 0.9.7+1
6+
version: 0.9.7+2
77

88
flutter:
99
plugin:
@@ -27,4 +27,4 @@ dev_dependencies:
2727

2828
environment:
2929
sdk: ">=2.0.0-dev.28.0 <3.0.0"
30-
flutter: ">=0.2.4 <2.0.0"
30+
flutter: ">=1.2.0 <2.0.0"

0 commit comments

Comments
 (0)