Skip to content

Commit

Permalink
Supress strong_mode_implicit_dynamic_method for invokeMethod call…
Browse files Browse the repository at this point in the history
…s. (flutter#1065)

flutter/flutter#26303 added a template argument to `invokeMethod`, which triggers the `strong_mode_implicit_dynamic_method` analyzer warning in many call sites in the plugins repo.

We should add the type parameter to all these call sites, but we can only do that after bumping the Flutter dependency constraint which we will only do once the `invokeMethod` change makes it to the stable release.

For now we're suppressing the warning in all call sites (we're not disabling the lint wholesale as we still want it for the rest of the code)

See: flutter/flutter#26431
  • Loading branch information
amirh authored Jan 12, 2019
1 parent 0a10e5e commit 340c47f
Show file tree
Hide file tree
Showing 31 changed files with 396 additions and 0 deletions.
18 changes: 18 additions & 0 deletions packages/cloud_firestore/lib/src/document_reference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class DocumentReference {
/// If [merge] is true, the provided data will be merged into an
/// existing document instead of overwriting.
Future<void> setData(Map<String, dynamic> data, {bool merge = false}) {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
return Firestore.channel.invokeMethod(
'DocumentReference#setData',
<String, dynamic>{
Expand All @@ -58,6 +61,9 @@ class DocumentReference {
///
/// If no document exists yet, the update will fail.
Future<void> updateData(Map<String, dynamic> data) {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
return Firestore.channel.invokeMethod(
'DocumentReference#updateData',
<String, dynamic>{
Expand All @@ -72,6 +78,9 @@ class DocumentReference {
///
/// If no document exists, the read will return null.
Future<DocumentSnapshot> get() async {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
final Map<dynamic, dynamic> data = await Firestore.channel.invokeMethod(
'DocumentReference#get',
<String, dynamic>{'app': firestore.app.name, 'path': path},
Expand All @@ -85,6 +94,9 @@ class DocumentReference {

/// Deletes the document referred to by this [DocumentReference].
Future<void> delete() {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
return Firestore.channel.invokeMethod(
'DocumentReference#delete',
<String, dynamic>{'app': firestore.app.name, 'path': path},
Expand All @@ -108,6 +120,9 @@ class DocumentReference {
StreamController<DocumentSnapshot> controller; // ignore: close_sinks
controller = StreamController<DocumentSnapshot>.broadcast(
onListen: () {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
_handle = Firestore.channel.invokeMethod(
'Query#addDocumentListener',
<String, dynamic>{
Expand All @@ -121,6 +136,9 @@ class DocumentReference {
},
onCancel: () {
_handle.then((int handle) async {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await Firestore.channel.invokeMethod(
'Query#removeListener',
<String, dynamic>{'handle': handle},
Expand Down
9 changes: 9 additions & 0 deletions packages/cloud_firestore/lib/src/firestore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ class Firestore {
final int transactionId = _transactionHandlerId++;
_transactionHandlers[transactionId] = transactionHandler;
final Map<dynamic, dynamic> result = await channel
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
.invokeMethod('Firestore#runTransaction', <String, dynamic>{
'app': app.name,
'transactionId': transactionId,
Expand All @@ -122,6 +125,9 @@ class Firestore {
@deprecated
Future<void> enablePersistence(bool enable) async {
assert(enable != null);
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await channel.invokeMethod('Firestore#enablePersistence', <String, dynamic>{
'app': app.name,
'enable': enable,
Expand All @@ -133,6 +139,9 @@ class Firestore {
String host,
bool sslEnabled,
bool timestampsInSnapshotsEnabled}) async {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await channel.invokeMethod('Firestore#settings', <String, dynamic>{
'app': app.name,
'persistenceEnabled': persistenceEnabled,
Expand Down
9 changes: 9 additions & 0 deletions packages/cloud_firestore/lib/src/query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class Query {
StreamController<QuerySnapshot> controller; // ignore: close_sinks
controller = StreamController<QuerySnapshot>.broadcast(
onListen: () {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
_handle = Firestore.channel.invokeMethod(
'Query#addSnapshotListener',
<String, dynamic>{
Expand All @@ -67,6 +70,9 @@ class Query {
},
onCancel: () {
_handle.then((int handle) async {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await Firestore.channel.invokeMethod(
'Query#removeListener',
<String, dynamic>{'handle': handle},
Expand All @@ -80,6 +86,9 @@ class Query {

/// Fetch the documents for this query
Future<QuerySnapshot> getDocuments() async {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
final Map<dynamic, dynamic> data = await Firestore.channel.invokeMethod(
'Query#getDocuments',
<String, dynamic>{
Expand Down
12 changes: 12 additions & 0 deletions packages/cloud_firestore/lib/src/transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class Transaction {

Future<DocumentSnapshot> get(DocumentReference documentReference) async {
final dynamic result = await Firestore.channel
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
.invokeMethod('Transaction#get', <String, dynamic>{
'app': _firestore.app.name,
'transactionId': _transactionId,
Expand All @@ -30,6 +33,9 @@ class Transaction {

Future<void> delete(DocumentReference documentReference) async {
return Firestore.channel
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
.invokeMethod('Transaction#delete', <String, dynamic>{
'app': _firestore.app.name,
'transactionId': _transactionId,
Expand All @@ -40,6 +46,9 @@ class Transaction {
Future<void> update(
DocumentReference documentReference, Map<String, dynamic> data) async {
return Firestore.channel
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
.invokeMethod('Transaction#update', <String, dynamic>{
'app': _firestore.app.name,
'transactionId': _transactionId,
Expand All @@ -50,6 +59,9 @@ class Transaction {

Future<void> set(
DocumentReference documentReference, Map<String, dynamic> data) async {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
return Firestore.channel.invokeMethod('Transaction#set', <String, dynamic>{
'app': _firestore.app.name,
'transactionId': _transactionId,
Expand Down
15 changes: 15 additions & 0 deletions packages/cloud_firestore/lib/src/write_batch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ part of cloud_firestore;
/// nor can it be committed again.
class WriteBatch {
WriteBatch._(this._firestore)
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
: _handle = Firestore.channel.invokeMethod(
'WriteBatch#create', <String, dynamic>{'app': _firestore.app.name});

Expand All @@ -29,6 +32,9 @@ class WriteBatch {
if (!_committed) {
_committed = true;
await Future.wait<dynamic>(_actions);
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await Firestore.channel.invokeMethod(
'WriteBatch#commit', <String, dynamic>{'handle': await _handle});
} else {
Expand All @@ -41,6 +47,9 @@ class WriteBatch {
if (!_committed) {
_handle.then((dynamic handle) {
_actions.add(
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
Firestore.channel.invokeMethod(
'WriteBatch#delete',
<String, dynamic>{
Expand Down Expand Up @@ -68,6 +77,9 @@ class WriteBatch {
if (!_committed) {
_handle.then((dynamic handle) {
_actions.add(
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
Firestore.channel.invokeMethod(
'WriteBatch#setData',
<String, dynamic>{
Expand All @@ -93,6 +105,9 @@ class WriteBatch {
if (!_committed) {
_handle.then((dynamic handle) {
_actions.add(
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
Firestore.channel.invokeMethod(
'WriteBatch#updateData',
<String, dynamic>{
Expand Down
3 changes: 3 additions & 0 deletions packages/cloud_functions/lib/cloud_functions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class CloudFunctions {
{@required String functionName, Map<String, dynamic> parameters}) async {
try {
final dynamic response =
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await channel.invokeMethod('CloudFunctions#call', <String, dynamic>{
'functionName': functionName,
'parameters': parameters,
Expand Down
3 changes: 3 additions & 0 deletions packages/firebase_admob/lib/firebase_admob.dart
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,9 @@ class FirebaseAdMob {
}

Future<bool> _invokeBooleanMethod(String method, [dynamic arguments]) async {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
final bool result = await FirebaseAdMob.instance._channel.invokeMethod(
method,
arguments,
Expand Down
21 changes: 21 additions & 0 deletions packages/firebase_analytics/lib/firebase_analytics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class FirebaseAnalytics {
'Prefix "$kReservedPrefix" is reserved and cannot be used.');
}

// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await _channel.invokeMethod('logEvent', <String, dynamic>{
'name': name,
'parameters': parameters,
Expand All @@ -67,6 +70,9 @@ class FirebaseAnalytics {
///
/// [1]: https://www.google.com/policies/privacy/
Future<void> setUserId(String id) async {
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await _channel.invokeMethod('setUserId', id);
}

Expand Down Expand Up @@ -94,6 +100,9 @@ class FirebaseAnalytics {
throw ArgumentError.notNull('screenName');
}

// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await _channel.invokeMethod('setCurrentScreen', <String, String>{
'screenName': screenName,
'screenClassOverride': screenClassOverride,
Expand Down Expand Up @@ -128,6 +137,9 @@ class FirebaseAnalytics {
if (name.startsWith('firebase_'))
throw ArgumentError.value(name, 'name', '"firebase_" prefix is reserved');

// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await _channel.invokeMethod('setUserProperty', <String, String>{
'name': name,
'value': value,
Expand Down Expand Up @@ -787,6 +799,9 @@ class FirebaseAnalyticsAndroid {
throw ArgumentError.notNull('enabled');
}

// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await _channel.invokeMethod('setAnalyticsCollectionEnabled', enabled);
}

Expand All @@ -798,6 +813,9 @@ class FirebaseAnalyticsAndroid {
throw ArgumentError.notNull('milliseconds');
}

// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await _channel.invokeMethod('setMinimumSessionDuration', milliseconds);
}

Expand All @@ -809,6 +827,9 @@ class FirebaseAnalyticsAndroid {
throw ArgumentError.notNull('milliseconds');
}

// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
await _channel.invokeMethod('setSessionTimeoutDuration', milliseconds);
}
}
Expand Down
9 changes: 9 additions & 0 deletions packages/firebase_analytics/test/firebase_analytics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ void main() {
invokedMethod = null;
arguments = null;

// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
when(mockChannel.invokeMethod(any, any))
.thenAnswer((Invocation invocation) {
invokedMethod = invocation.positionalArguments[0];
Expand Down Expand Up @@ -125,6 +128,9 @@ void main() {
name = null;
parameters = null;

// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
when(mockChannel.invokeMethod('logEvent', any))
.thenAnswer((Invocation invocation) {
final Map<String, dynamic> args = invocation.positionalArguments[1];
Expand All @@ -134,6 +140,9 @@ void main() {
return Future<void>.value();
});

// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
// https://github.com/flutter/flutter/issues/26431
// ignore: strong_mode_implicit_dynamic_method
when(mockChannel.invokeMethod(argThat(isNot('logEvent')), any))
.thenThrow(ArgumentError('Only logEvent invocations expected'));

Expand Down
Loading

0 comments on commit 340c47f

Please sign in to comment.