From 866e3cda1df9b099e723929824791418645073dc Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Wed, 17 Oct 2018 21:12:07 +0200 Subject: [PATCH] enable lint prefer_void_to_null --- analysis_options.yaml | 1 + .../example/lib/main.dart | 4 +- .../android_intent/lib/android_intent.dart | 2 +- packages/battery/example/lib/main.dart | 2 +- packages/camera/example/lib/main.dart | 2 +- packages/camera/lib/camera.dart | 37 +++++------ .../cloud_firestore/example/lib/main.dart | 2 +- .../cloud_firestore/lib/src/write_batch.dart | 4 +- .../test/cloud_firestore_test.dart | 10 +-- packages/connectivity/example/lib/main.dart | 2 +- packages/device_info/example/lib/main.dart | 2 +- .../firebase_admob/lib/firebase_admob.dart | 2 +- .../firebase_analytics/example/lib/main.dart | 16 ++--- .../lib/firebase_analytics.dart | 66 +++++++++---------- .../test/firebase_analytics_test.dart | 4 +- packages/firebase_auth/lib/firebase_auth.dart | 3 +- .../test/firebase_auth_test.dart | 6 +- packages/firebase_core/example/lib/main.dart | 6 +- .../firebase_database/example/lib/main.dart | 2 +- .../test/firebase_database_test.dart | 12 ++-- .../firebase_messaging/example/lib/main.dart | 6 +- .../lib/firebase_messaging.dart | 2 +- .../firebase_storage/example/lib/main.dart | 4 +- .../lib/src/controller.dart | 2 +- packages/google_sign_in/example/lib/main.dart | 6 +- packages/local_auth/example/lib/main.dart | 6 +- packages/package_info/example/lib/main.dart | 2 +- packages/quick_actions/lib/quick_actions.dart | 4 +- packages/sensors/test/sensors_test.dart | 2 +- .../shared_preferences/example/lib/main.dart | 2 +- packages/url_launcher/example/lib/main.dart | 12 ++-- .../test/webview_flutter_test.dart | 6 +- 32 files changed, 118 insertions(+), 121 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 51b9c0d266d8..a73c3a63e1bb 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -112,6 +112,7 @@ linter: # - prefer_interpolation_to_compose_strings # not yet tested - prefer_is_empty - prefer_is_not_empty + - prefer_void_to_null # - recursive_getters # https://github.com/dart-lang/linter/issues/452 - slash_for_doc_comments - sort_constructors_first diff --git a/packages/android_alarm_manager/example/lib/main.dart b/packages/android_alarm_manager/example/lib/main.dart index 8424920ddd4e..0c7fc2a2cd7e 100644 --- a/packages/android_alarm_manager/example/lib/main.dart +++ b/packages/android_alarm_manager/example/lib/main.dart @@ -12,7 +12,7 @@ import 'package:flutter/widgets.dart'; final FirebaseAuth firebaseAuth = FirebaseAuth.instance; FirebaseUser firebaseUser; -Future ensureFirebaseUser() async { +Future ensureFirebaseUser() async { if (firebaseUser == null) { firebaseUser = await firebaseAuth.currentUser(); if (firebaseUser == null) { @@ -67,7 +67,7 @@ void printOneShot() { printHelloMessage("Hello, once!"); } -Future main() async { +Future main() async { final int helloAlarmID = 0; final int goodbyeAlarmID = 1; final int oneShotID = 2; diff --git a/packages/android_intent/lib/android_intent.dart b/packages/android_intent/lib/android_intent.dart index 5409d857713c..962bc5f849ba 100644 --- a/packages/android_intent/lib/android_intent.dart +++ b/packages/android_intent/lib/android_intent.dart @@ -42,7 +42,7 @@ class AndroidIntent { /// /// This works only on Android platforms. Please guard the call so that your /// iOS app does not crash. Checked mode will throw an assert exception. - Future launch() async { + Future launch() async { assert(_platform.isAndroid); final Map args = {'action': action}; if (category != null) { diff --git a/packages/battery/example/lib/main.dart b/packages/battery/example/lib/main.dart index 4bf9a58939fc..250d458d5190 100644 --- a/packages/battery/example/lib/main.dart +++ b/packages/battery/example/lib/main.dart @@ -63,7 +63,7 @@ class _MyHomePageState extends State { child: const Icon(Icons.battery_unknown), onPressed: () async { final int batteryLevel = await _battery.batteryLevel; - showDialog( + showDialog( context: context, builder: (_) => AlertDialog( content: Text('Battery: $batteryLevel%'), diff --git a/packages/camera/example/lib/main.dart b/packages/camera/example/lib/main.dart index a0eed3ca7de6..ca01a7ac0f57 100644 --- a/packages/camera/example/lib/main.dart +++ b/packages/camera/example/lib/main.dart @@ -356,7 +356,7 @@ class CameraApp extends StatelessWidget { List cameras; -Future main() async { +Future main() async { // Fetch the available cameras before initializing the app. try { cameras = await availableCameras(); diff --git a/packages/camera/lib/camera.dart b/packages/camera/lib/camera.dart index baae0f9634cc..153bbeb69b98 100644 --- a/packages/camera/lib/camera.dart +++ b/packages/camera/lib/camera.dart @@ -185,17 +185,17 @@ class CameraController extends ValueNotifier { int _textureId; bool _isDisposed = false; StreamSubscription _eventSubscription; - Completer _creatingCompleter; + Completer _creatingCompleter; /// Initializes the camera on the device. /// /// Throws a [CameraException] if the initialization fails. - Future initialize() async { + Future initialize() async { if (_isDisposed) { - return Future.value(null); + return Future.value(); } try { - _creatingCompleter = Completer(); + _creatingCompleter = Completer(); final Map reply = await _channel.invokeMethod( 'initialize', { @@ -218,7 +218,7 @@ class CameraController extends ValueNotifier { EventChannel('flutter.io/cameraPlugin/cameraEvents$_textureId') .receiveBroadcastStream() .listen(_listener); - _creatingCompleter.complete(null); + _creatingCompleter.complete(); return _creatingCompleter.future; } @@ -250,7 +250,7 @@ class CameraController extends ValueNotifier { /// The file can be read as this function returns. /// /// Throws a [CameraException] if the capture fails. - Future takePicture(String path) async { + Future takePicture(String path) async { if (!value.isInitialized || _isDisposed) { throw CameraException( 'Uninitialized CameraController.', @@ -286,7 +286,7 @@ class CameraController extends ValueNotifier { /// The file can be read as soon as [stopVideoRecording] returns. /// /// Throws a [CameraException] if the capture fails. - Future startVideoRecording(String filePath) async { + Future startVideoRecording(String filePath) async { if (!value.isInitialized || _isDisposed) { throw CameraException( 'Uninitialized CameraController', @@ -311,7 +311,7 @@ class CameraController extends ValueNotifier { } /// Stop recording. - Future stopVideoRecording() async { + Future stopVideoRecording() async { if (!value.isInitialized || _isDisposed) { throw CameraException( 'Uninitialized CameraController', @@ -337,22 +337,19 @@ class CameraController extends ValueNotifier { /// Releases the resources of this camera. @override - Future dispose() async { + Future dispose() async { if (_isDisposed) { - return Future.value(null); + return; } _isDisposed = true; super.dispose(); - if (_creatingCompleter == null) { - return Future.value(null); - } else { - return _creatingCompleter.future.then((_) async { - await _channel.invokeMethod( - 'dispose', - {'textureId': _textureId}, - ); - await _eventSubscription?.cancel(); - }); + if (_creatingCompleter != null) { + await _creatingCompleter.future; + await _channel.invokeMethod( + 'dispose', + {'textureId': _textureId}, + ); + await _eventSubscription?.cancel(); } } } diff --git a/packages/cloud_firestore/example/lib/main.dart b/packages/cloud_firestore/example/lib/main.dart index e2be166e7ed4..36a12f84c2cb 100755 --- a/packages/cloud_firestore/example/lib/main.dart +++ b/packages/cloud_firestore/example/lib/main.dart @@ -56,7 +56,7 @@ class MyHomePage extends StatelessWidget { final Firestore firestore; CollectionReference get messages => firestore.collection('messages'); - Future _addMessage() async { + Future _addMessage() async { final DocumentReference document = messages.document(); document.setData({ 'message': 'Hello world!', diff --git a/packages/cloud_firestore/lib/src/write_batch.dart b/packages/cloud_firestore/lib/src/write_batch.dart index b9ffc14f34bf..ea1f0851d1c3 100644 --- a/packages/cloud_firestore/lib/src/write_batch.dart +++ b/packages/cloud_firestore/lib/src/write_batch.dart @@ -25,11 +25,11 @@ class WriteBatch { /// Commits all of the writes in this write batch as a single atomic unit. /// /// Calling this method prevents any future operations from being added. - Future commit() async { + Future commit() async { if (!_committed) { _committed = true; await Future.wait(_actions); - return await Firestore.channel.invokeMethod( + await Firestore.channel.invokeMethod( 'WriteBatch#commit', {'handle': await _handle}); } else { throw StateError("This batch has already been committed."); diff --git a/packages/cloud_firestore/test/cloud_firestore_test.dart b/packages/cloud_firestore/test/cloud_firestore_test.dart index 99232756f077..8c35acb8a50f 100755 --- a/packages/cloud_firestore/test/cloud_firestore_test.dart +++ b/packages/cloud_firestore/test/cloud_firestore_test.dart @@ -279,7 +279,7 @@ void main() { expect(document.reference.path, equals('foo/0')); expect(document.data, equals(kMockDocumentSnapshotData)); // Flush the async removeListener call - await Future.delayed(Duration.zero); + await Future.delayed(Duration.zero); expect(log, [ isMethodCall( 'Query#addSnapshotListener', @@ -305,7 +305,7 @@ void main() { .snapshots() .listen((QuerySnapshot querySnapshot) {}); subscription.cancel(); - await Future.delayed(Duration.zero); + await Future.delayed(Duration.zero); expect( log, equals([ @@ -336,7 +336,7 @@ void main() { .snapshots() .listen((QuerySnapshot querySnapshot) {}); subscription.cancel(); - await Future.delayed(Duration.zero); + await Future.delayed(Duration.zero); expect( log, equals([ @@ -367,7 +367,7 @@ void main() { .snapshots() .listen((QuerySnapshot querySnapshot) {}); subscription.cancel(); - await Future.delayed(Duration.zero); + await Future.delayed(Duration.zero); expect( log, equals([ @@ -401,7 +401,7 @@ void main() { expect(snapshot.reference.path, equals('path/to/foo')); expect(snapshot.data, equals(kMockDocumentSnapshotData)); // Flush the async removeListener call - await Future.delayed(Duration.zero); + await Future.delayed(Duration.zero); expect( log, [ diff --git a/packages/connectivity/example/lib/main.dart b/packages/connectivity/example/lib/main.dart index 35696fc10131..ccb4ebe5001b 100644 --- a/packages/connectivity/example/lib/main.dart +++ b/packages/connectivity/example/lib/main.dart @@ -57,7 +57,7 @@ class _MyHomePageState extends State { } // Platform messages are asynchronous, so we initialize in an async method. - Future initConnectivity() async { + Future initConnectivity() async { String connectionStatus; // Platform messages may fail, so we use a try/catch PlatformException. try { diff --git a/packages/device_info/example/lib/main.dart b/packages/device_info/example/lib/main.dart index 58cf460334f8..6ffae432c48b 100644 --- a/packages/device_info/example/lib/main.dart +++ b/packages/device_info/example/lib/main.dart @@ -33,7 +33,7 @@ class _MyAppState extends State { initPlatformState(); } - Future initPlatformState() async { + Future initPlatformState() async { Map deviceData; try { diff --git a/packages/firebase_admob/lib/firebase_admob.dart b/packages/firebase_admob/lib/firebase_admob.dart index 7b7ad9eb9900..aca3ee53bbf8 100644 --- a/packages/firebase_admob/lib/firebase_admob.dart +++ b/packages/firebase_admob/lib/firebase_admob.dart @@ -501,7 +501,7 @@ class FirebaseAdMob { } } - return Future(null); + return Future.value(null); } } diff --git a/packages/firebase_analytics/example/lib/main.dart b/packages/firebase_analytics/example/lib/main.dart index 6864e594439a..644955283730 100755 --- a/packages/firebase_analytics/example/lib/main.dart +++ b/packages/firebase_analytics/example/lib/main.dart @@ -61,7 +61,7 @@ class _MyHomePageState extends State { }); } - Future _sendAnalyticsEvent() async { + Future _sendAnalyticsEvent() async { await analytics.logEvent( name: 'test_event', parameters: { @@ -75,12 +75,12 @@ class _MyHomePageState extends State { setMessage('logEvent succeeded'); } - Future _testSetUserId() async { + Future _testSetUserId() async { await analytics.setUserId('some-user'); setMessage('setUserId succeeded'); } - Future _testSetCurrentScreen() async { + Future _testSetCurrentScreen() async { await analytics.setCurrentScreen( screenName: 'Analytics Demo', screenClassOverride: 'AnalyticsDemo', @@ -88,28 +88,28 @@ class _MyHomePageState extends State { setMessage('setCurrentScreen succeeded'); } - Future _testSetAnalyticsCollectionEnabled() async { + Future _testSetAnalyticsCollectionEnabled() async { await analytics.android?.setAnalyticsCollectionEnabled(false); await analytics.android?.setAnalyticsCollectionEnabled(true); setMessage('setAnalyticsCollectionEnabled succeeded'); } - Future _testSetMinimumSessionDuration() async { + Future _testSetMinimumSessionDuration() async { await analytics.android?.setMinimumSessionDuration(20000); setMessage('setMinimumSessionDuration succeeded'); } - Future _testSetSessionTimeoutDuration() async { + Future _testSetSessionTimeoutDuration() async { await analytics.android?.setSessionTimeoutDuration(2000000); setMessage('setSessionTimeoutDuration succeeded'); } - Future _testSetUserProperty() async { + Future _testSetUserProperty() async { await analytics.setUserProperty(name: 'regular', value: 'indeed'); setMessage('setUserProperty succeeded'); } - Future _testAllEventTypes() async { + Future _testAllEventTypes() async { await analytics.logAddPaymentInfo(); await analytics.logAddToCart( currency: 'USD', diff --git a/packages/firebase_analytics/lib/firebase_analytics.dart b/packages/firebase_analytics/lib/firebase_analytics.dart index 034968f03261..e9764df855c1 100755 --- a/packages/firebase_analytics/lib/firebase_analytics.dart +++ b/packages/firebase_analytics/lib/firebase_analytics.dart @@ -41,7 +41,7 @@ class FirebaseAnalytics { final FirebaseAnalyticsAndroid android; /// Logs a custom Flutter Analytics event with the given [name] and event [parameters]. - Future logEvent( + Future logEvent( {@required String name, Map parameters}) async { if (_reservedEventNames.contains(name)) { throw ArgumentError.value( @@ -66,7 +66,7 @@ class FirebaseAnalytics { /// This feature must be used in accordance with [Google's Privacy Policy][1]. /// /// [1]: https://www.google.com/policies/privacy/ - Future setUserId(String id) async { + Future setUserId(String id) async { if (id == null) { throw ArgumentError.notNull('id'); } @@ -91,7 +91,7 @@ class FirebaseAnalytics { /// /// https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.html#setCurrentScreen(android.app.Activity, java.lang.String, java.lang.String) /// https://firebase.google.com/docs/reference/ios/firebaseanalytics/api/reference/Classes/FIRAnalytics#setscreennamescreenclass - Future setCurrentScreen( + Future setCurrentScreen( {@required String screenName, String screenClassOverride = 'Flutter'}) async { if (screenName == null) { @@ -116,7 +116,7 @@ class FirebaseAnalytics { /// alphanumeric characters or underscores and must start with an alphabetic /// character. The "firebase_" prefix is reserved and should not be used for /// user property names. - Future setUserProperty( + Future setUserProperty( {@required String name, @required String value}) async { if (name == null) { throw ArgumentError.notNull('name'); @@ -144,7 +144,7 @@ class FirebaseAnalytics { /// to your app. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#ADD_PAYMENT_INFO - Future logAddPaymentInfo() { + Future logAddPaymentInfo() { return logEvent(name: 'add_payment_info'); } @@ -157,7 +157,7 @@ class FirebaseAnalytics { /// revenue metrics can be computed accurately. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#ADD_TO_CART - Future logAddToCart({ + Future logAddToCart({ @required String itemId, @required String itemName, @required String itemCategory, @@ -200,7 +200,7 @@ class FirebaseAnalytics { /// revenue metrics can be computed accurately. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#ADD_TO_WISHLIST - Future logAddToWishlist({ + Future logAddToWishlist({ @required String itemId, @required String itemName, @required String itemCategory, @@ -230,7 +230,7 @@ class FirebaseAnalytics { /// Logs the standard `app_open` event. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#APP_OPEN - Future logAppOpen() { + Future logAppOpen() { return logEvent(name: 'app_open'); } @@ -243,7 +243,7 @@ class FirebaseAnalytics { /// revenue metrics can be computed accurately. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#BEGIN_CHECKOUT - Future logBeginCheckout({ + Future logBeginCheckout({ double value, String currency, String transactionId, @@ -281,7 +281,7 @@ class FirebaseAnalytics { /// Log this event to supply the referral details of a re-engagement campaign. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#CAMPAIGN_DETAILS - Future logCampaignDetails({ + Future logCampaignDetails({ @required String source, @required String medium, @required String campaign, @@ -311,7 +311,7 @@ class FirebaseAnalytics { /// economy. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#EARN_VIRTUAL_CURRENCY - Future logEarnVirtualCurrency({ + Future logEarnVirtualCurrency({ @required String virtualCurrencyName, @required num value, }) { @@ -333,7 +333,7 @@ class FirebaseAnalytics { /// be computed accurately. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#ECOMMERCE_PURCHASE - Future logEcommercePurchase({ + Future logEcommercePurchase({ String currency, double value, String transactionId, @@ -382,7 +382,7 @@ class FirebaseAnalytics { /// parameter so that revenue metrics can be computed accurately. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#GENERATE_LEAD - Future logGenerateLead({ + Future logGenerateLead({ String currency, double value, }) { @@ -404,7 +404,7 @@ class FirebaseAnalytics { /// are in your app. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#JOIN_GROUP - Future logJoinGroup({ + Future logJoinGroup({ @required String groupId, }) { return logEvent( @@ -422,7 +422,7 @@ class FirebaseAnalytics { /// identify certain levels that are difficult to pass. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#LEVEL_UP - Future logLevelUp({ + Future logLevelUp({ @required int level, String character, }) { @@ -441,7 +441,7 @@ class FirebaseAnalytics { /// has logged in. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#LOGIN - Future logLogin() { + Future logLogin() { return logEvent(name: 'login'); } @@ -453,7 +453,7 @@ class FirebaseAnalytics { /// behaviors. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#POST_SCORE - Future logPostScore({ + Future logPostScore({ @required int score, int level, String character, @@ -477,7 +477,7 @@ class FirebaseAnalytics { /// parameter so that revenue metrics can be computed accurately. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#PRESENT_OFFER - Future logPresentOffer({ + Future logPresentOffer({ @required String itemId, @required String itemName, @required String itemCategory, @@ -511,7 +511,7 @@ class FirebaseAnalytics { /// parameter so that revenue metrics can be computed accurately. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#PURCHASE_REFUND - Future logPurchaseRefund({ + Future logPurchaseRefund({ String currency, double value, String transactionId, @@ -535,7 +535,7 @@ class FirebaseAnalytics { /// This event can help you identify the most popular content in your app. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#SEARCH - Future logSearch({ + Future logSearch({ @required String searchTerm, int numberOfNights, int numberOfRooms, @@ -570,7 +570,7 @@ class FirebaseAnalytics { /// of content in your app. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#SELECT_CONTENT - Future logSelectContent({ + Future logSelectContent({ @required String contentType, @required String itemId, }) { @@ -589,7 +589,7 @@ class FirebaseAnalytics { /// viral content. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#SHARE - Future logShare({ + Future logShare({ @required String contentType, @required String itemId, }) { @@ -610,7 +610,7 @@ class FirebaseAnalytics { /// logged out users. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#SIGN_UP - Future logSignUp({ + Future logSignUp({ @required String signUpMethod, }) { return logEvent( @@ -627,7 +627,7 @@ class FirebaseAnalytics { /// identify which virtual goods are the most popular objects of purchase. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#SPEND_VIRTUAL_CURRENCY - Future logSpendVirtualCurrency({ + Future logSpendVirtualCurrency({ @required String itemName, @required String virtualCurrencyName, @required num value, @@ -649,7 +649,7 @@ class FirebaseAnalytics { /// users complete this process and move on to the full app experience. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#TUTORIAL_BEGIN - Future logTutorialBegin() { + Future logTutorialBegin() { return logEvent(name: 'tutorial_begin'); } @@ -660,7 +660,7 @@ class FirebaseAnalytics { /// completion rate of your on-boarding process. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#TUTORIAL_COMPLETE - Future logTutorialComplete() { + Future logTutorialComplete() { return logEvent(name: 'tutorial_complete'); } @@ -673,7 +673,7 @@ class FirebaseAnalytics { /// experiencing all that your game has to offer. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#UNLOCK_ACHIEVEMENT - Future logUnlockAchievement({ + Future logUnlockAchievement({ @required String id, }) { return logEvent( @@ -694,7 +694,7 @@ class FirebaseAnalytics { /// that revenue metrics can be computed accurately. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#VIEW_ITEM - Future logViewItem({ + Future logViewItem({ @required String itemId, @required String itemName, @required String itemCategory, @@ -747,7 +747,7 @@ class FirebaseAnalytics { /// certain category. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#VIEW_ITEM_LIST - Future logViewItemList({ + Future logViewItemList({ @required String itemCategory, }) { return logEvent( @@ -764,7 +764,7 @@ class FirebaseAnalytics { /// search. /// /// See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#VIEW_SEARCH_RESULTS - Future logViewSearchResults({ + Future logViewSearchResults({ @required String searchTerm, }) { return logEvent( @@ -786,7 +786,7 @@ class FirebaseAnalyticsAndroid { /// Sets whether analytics collection is enabled for this app on this device. /// /// This setting is persisted across app sessions. By default it is enabled. - Future setAnalyticsCollectionEnabled(bool enabled) async { + Future setAnalyticsCollectionEnabled(bool enabled) async { if (enabled == null) { throw ArgumentError.notNull('enabled'); } @@ -797,7 +797,7 @@ class FirebaseAnalyticsAndroid { /// Sets the minimum engagement time required before starting a session. /// /// The default value is 10000 (10 seconds). - Future setMinimumSessionDuration(int milliseconds) async { + Future setMinimumSessionDuration(int milliseconds) async { if (milliseconds == null) { throw ArgumentError.notNull('milliseconds'); } @@ -808,7 +808,7 @@ class FirebaseAnalyticsAndroid { /// Sets the duration of inactivity that terminates the current session. /// /// The default value is 1800000 (30 minutes). - Future setSessionTimeoutDuration(int milliseconds) async { + Future setSessionTimeoutDuration(int milliseconds) async { if (milliseconds == null) { throw ArgumentError.notNull('milliseconds'); } diff --git a/packages/firebase_analytics/test/firebase_analytics_test.dart b/packages/firebase_analytics/test/firebase_analytics_test.dart index a4718c1b2b0a..67372733bd26 100755 --- a/packages/firebase_analytics/test/firebase_analytics_test.dart +++ b/packages/firebase_analytics/test/firebase_analytics_test.dart @@ -155,7 +155,7 @@ void main() { expect(analytics.logEvent(name: 'firebase_foo'), throwsArgumentError); }); - void smokeTest(String testFunctionName, Future testFunction()) { + void smokeTest(String testFunctionName, Future testFunction()) { test('$testFunctionName works', () async { await testFunction(); expect(name, testFunctionName); @@ -301,7 +301,7 @@ void main() { )); void testRequiresValueAndCurrencyTogether( - String methodName, Future testFn()) { + String methodName, Future testFn()) { test('$methodName requires value and currency together', () async { try { testFn(); diff --git a/packages/firebase_auth/lib/firebase_auth.dart b/packages/firebase_auth/lib/firebase_auth.dart index 5b5328b2302d..45a177331b91 100755 --- a/packages/firebase_auth/lib/firebase_auth.dart +++ b/packages/firebase_auth/lib/firebase_auth.dart @@ -474,7 +474,7 @@ class FirebaseAuth { }); } - Future _callHandler(MethodCall call) async { + Future _callHandler(MethodCall call) async { switch (call.method) { case 'onAuthStateChanged': _onAuthStageChangedHandler(call); @@ -514,7 +514,6 @@ class FirebaseAuth { codeAutoRetrievalTimeout(verificationId); break; } - return null; } void _onAuthStageChangedHandler(MethodCall call) { diff --git a/packages/firebase_auth/test/firebase_auth_test.dart b/packages/firebase_auth/test/firebase_auth_test.dart index 06b0814ce052..d5f0e3146ee7 100755 --- a/packages/firebase_auth/test/firebase_auth_test.dart +++ b/packages/firebase_auth/test/firebase_auth_test.dart @@ -453,7 +453,7 @@ void main() { test('onAuthStateChanged', () async { mockHandleId = 42; - Future simulateEvent(Map user) async { + Future simulateEvent(Map user) async { await BinaryMessages.handlePlatformMessage( FirebaseAuth.channel.name, FirebaseAuth.channel.codec.encodeMethodCall( @@ -471,7 +471,7 @@ void main() { // Subscribe and allow subscription to complete. final StreamSubscription subscription = auth.onAuthStateChanged.listen(events.add); - await Future.delayed(const Duration(seconds: 0)); + await Future.delayed(const Duration(seconds: 0)); await simulateEvent(null); await simulateEvent(mockFirebaseUser()); @@ -484,7 +484,7 @@ void main() { // Cancel subscription and allow cancellation to complete. subscription.cancel(); - await Future.delayed(const Duration(seconds: 0)); + await Future.delayed(const Duration(seconds: 0)); expect( log, diff --git a/packages/firebase_core/example/lib/main.dart b/packages/firebase_core/example/lib/main.dart index f0e603a4ff3e..de231536c911 100644 --- a/packages/firebase_core/example/lib/main.dart +++ b/packages/firebase_core/example/lib/main.dart @@ -12,7 +12,7 @@ class MyApp extends StatelessWidget { apiKey: 'AIzaSyBq6mcufFXfyqr79uELCiqM_O_1-G72PVU', ); - Future _configure() async { + Future _configure() async { final FirebaseApp app = await FirebaseApp.configure( name: name, options: options, @@ -21,12 +21,12 @@ class MyApp extends StatelessWidget { print('Configured $app'); } - Future _allApps() async { + Future _allApps() async { final List apps = await FirebaseApp.allApps(); print('Currently configured apps: $apps'); } - Future _options() async { + Future _options() async { final FirebaseApp app = await FirebaseApp.appNamed(name); final FirebaseOptions options = await app?.options; print('Current options for app $name: $options'); diff --git a/packages/firebase_database/example/lib/main.dart b/packages/firebase_database/example/lib/main.dart index 79865c9c5411..0430e66434b7 100755 --- a/packages/firebase_database/example/lib/main.dart +++ b/packages/firebase_database/example/lib/main.dart @@ -92,7 +92,7 @@ class _MyHomePageState extends State { _counterSubscription.cancel(); } - Future _increment() async { + Future _increment() async { // Increment counter in transaction. final TransactionResult transactionResult = await _counterRef.runTransaction((MutableData mutableData) async { diff --git a/packages/firebase_database/test/firebase_database_test.dart b/packages/firebase_database/test/firebase_database_test.dart index bb79a1cdc0f4..653fc2a484ea 100755 --- a/packages/firebase_database/test/firebase_database_test.dart +++ b/packages/firebase_database/test/firebase_database_test.dart @@ -36,7 +36,7 @@ void main() { return true; case 'DatabaseReference#runTransaction': Map updatedValue; - Future simulateEvent( + Future simulateEvent( int transactionKey, final MutableData mutableData) async { await BinaryMessages.handlePlatformMessage( channel.name, @@ -454,7 +454,7 @@ void main() { const int errorCode = 12; const String errorDetails = 'Some details'; final Query query = database.reference().child('some path'); - Future simulateError(String errorMessage) async { + Future simulateError(String errorMessage) async { await BinaryMessages.handlePlatformMessage( channel.name, channel.codec.encodeMethodCall( @@ -476,7 +476,7 @@ void main() { // Subscribe and allow subscription to complete. final StreamSubscription subscription = query.onValue.listen((_) {}, onError: errors.add); - await Future.delayed(const Duration(seconds: 0)); + await Future.delayed(const Duration(seconds: 0)); await simulateError('Bad foo'); await simulateError('Bad bar'); @@ -494,7 +494,7 @@ void main() { mockHandleId = 87; final String path = 'foo'; final Query query = database.reference().child(path); - Future simulateEvent(String value) async { + Future simulateEvent(String value) async { await BinaryMessages.handlePlatformMessage( channel.name, channel.codec.encodeMethodCall( @@ -515,7 +515,7 @@ void main() { // Subscribe and allow subscription to complete. final StreamSubscription subscription = query.onValue.listen(events.add); - await Future.delayed(const Duration(seconds: 0)); + await Future.delayed(const Duration(seconds: 0)); await simulateEvent('1'); await simulateEvent('2'); @@ -528,7 +528,7 @@ void main() { // Cancel subscription and allow cancellation to complete. subscription.cancel(); - await Future.delayed(const Duration(seconds: 0)); + await Future.delayed(const Duration(seconds: 0)); expect( log, diff --git a/packages/firebase_messaging/example/lib/main.dart b/packages/firebase_messaging/example/lib/main.dart index ab464ee84e6d..8a24b939cc9d 100644 --- a/packages/firebase_messaging/example/lib/main.dart +++ b/packages/firebase_messaging/example/lib/main.dart @@ -29,12 +29,12 @@ class Item { _controller.add(this); } - static final Map> routes = >{}; - Route get route { + static final Map> routes = >{}; + Route get route { final String routeName = '/detail/$itemId'; return routes.putIfAbsent( routeName, - () => MaterialPageRoute( + () => MaterialPageRoute( settings: RouteSettings(name: routeName), builder: (BuildContext context) => DetailPage(itemId), ), diff --git a/packages/firebase_messaging/lib/firebase_messaging.dart b/packages/firebase_messaging/lib/firebase_messaging.dart index 4cacff8b3b3a..5822039121d5 100644 --- a/packages/firebase_messaging/lib/firebase_messaging.dart +++ b/packages/firebase_messaging/lib/firebase_messaging.dart @@ -96,7 +96,7 @@ class FirebaseMessaging { _channel.invokeMethod('unsubscribeFromTopic', topic); } - Future _handleMethod(MethodCall call) async { + Future _handleMethod(MethodCall call) async { switch (call.method) { case "onToken": final String token = call.arguments; diff --git a/packages/firebase_storage/example/lib/main.dart b/packages/firebase_storage/example/lib/main.dart index 5125e95e09fa..553ee8301642 100755 --- a/packages/firebase_storage/example/lib/main.dart +++ b/packages/firebase_storage/example/lib/main.dart @@ -55,7 +55,7 @@ class _MyHomePageState extends State { GlobalKey _scaffoldKey = GlobalKey(); List _tasks = []; - Future _uploadFile() async { + Future _uploadFile() async { final String uuid = Uuid().v1(); final Directory systemTempDir = Directory.systemTemp; final File file = await File('${systemTempDir.path}/foo$uuid.txt').create(); @@ -76,7 +76,7 @@ class _MyHomePageState extends State { }); } - Future _downloadFile(StorageReference ref) async { + Future _downloadFile(StorageReference ref) async { final String url = await ref.getDownloadURL(); final String uuid = Uuid().v1(); final http.Response downloadData = await http.get(url); diff --git a/packages/google_maps_flutter/lib/src/controller.dart b/packages/google_maps_flutter/lib/src/controller.dart index 01b05b4fe2db..629ab2a348ea 100644 --- a/packages/google_maps_flutter/lib/src/controller.dart +++ b/packages/google_maps_flutter/lib/src/controller.dart @@ -74,7 +74,7 @@ class GoogleMapController extends ChangeNotifier { final int _id; - Future _handleMethodCall(MethodCall call) async { + Future _handleMethodCall(MethodCall call) async { switch (call.method) { case 'infoWindow#onTap': final String markerId = call.arguments['marker']; diff --git a/packages/google_sign_in/example/lib/main.dart b/packages/google_sign_in/example/lib/main.dart index 75b2f4ca3808..390bba367e02 100755 --- a/packages/google_sign_in/example/lib/main.dart +++ b/packages/google_sign_in/example/lib/main.dart @@ -48,7 +48,7 @@ class SignInDemoState extends State { _googleSignIn.signInSilently(); } - Future _handleGetContact() async { + Future _handleGetContact() async { setState(() { _contactText = "Loading contact info..."; }); @@ -94,7 +94,7 @@ class SignInDemoState extends State { return null; } - Future _handleSignIn() async { + Future _handleSignIn() async { try { await _googleSignIn.signIn(); } catch (error) { @@ -102,7 +102,7 @@ class SignInDemoState extends State { } } - Future _handleSignOut() async { + Future _handleSignOut() async { _googleSignIn.disconnect(); } diff --git a/packages/local_auth/example/lib/main.dart b/packages/local_auth/example/lib/main.dart index 0d79acd86203..6d0d9f7f1f9c 100644 --- a/packages/local_auth/example/lib/main.dart +++ b/packages/local_auth/example/lib/main.dart @@ -22,7 +22,7 @@ class _MyAppState extends State { List _availableBiometrics; String _authorized = 'Not Authorized'; - Future _checkBiometrics() async { + Future _checkBiometrics() async { bool canCheckBiometrics; try { canCheckBiometrics = await auth.canCheckBiometrics; @@ -36,7 +36,7 @@ class _MyAppState extends State { }); } - Future _getAvailableBiometrics() async { + Future _getAvailableBiometrics() async { List availableBiometrics; try { availableBiometrics = await auth.getAvailableBiometrics(); @@ -50,7 +50,7 @@ class _MyAppState extends State { }); } - Future _authenticate() async { + Future _authenticate() async { bool authenticated = false; try { authenticated = await auth.authenticateWithBiometrics( diff --git a/packages/package_info/example/lib/main.dart b/packages/package_info/example/lib/main.dart index dca6908035dc..9edbce152657 100644 --- a/packages/package_info/example/lib/main.dart +++ b/packages/package_info/example/lib/main.dart @@ -45,7 +45,7 @@ class _MyHomePageState extends State { _initPackageInfo(); } - Future _initPackageInfo() async { + Future _initPackageInfo() async { final PackageInfo info = await PackageInfo.fromPlatform(); setState(() { _packageInfo = info; diff --git a/packages/quick_actions/lib/quick_actions.dart b/packages/quick_actions/lib/quick_actions.dart index 4d2acf99874f..7747495d37b8 100644 --- a/packages/quick_actions/lib/quick_actions.dart +++ b/packages/quick_actions/lib/quick_actions.dart @@ -49,14 +49,14 @@ class QuickActions { } /// Sets the [ShortcutItem]s to become the app's quick actions. - Future setShortcutItems(List items) async { + Future setShortcutItems(List items) async { final List> itemsList = items.map(_serializeItem).toList(); await _kChannel.invokeMethod('setShortcutItems', itemsList); } /// Removes all [ShortcutItem]s registered for the app. - Future clearShortcutItems() => + Future clearShortcutItems() => _kChannel.invokeMethod('clearShortcutItems'); Map _serializeItem(ShortcutItem item) { diff --git a/packages/sensors/test/sensors_test.dart b/packages/sensors/test/sensors_test.dart index 0867b3566bef..9bbbb49c6315 100644 --- a/packages/sensors/test/sensors_test.dart +++ b/packages/sensors/test/sensors_test.dart @@ -40,7 +40,7 @@ void main() { expect(event.y, 2.0); expect(event.z, 3.0); - await Future.delayed(Duration.zero); + await Future.delayed(Duration.zero); expect(isCanceled, isTrue); }); } diff --git a/packages/shared_preferences/example/lib/main.dart b/packages/shared_preferences/example/lib/main.dart index 97d22f8c662e..34347f89b844 100644 --- a/packages/shared_preferences/example/lib/main.dart +++ b/packages/shared_preferences/example/lib/main.dart @@ -32,7 +32,7 @@ class SharedPreferencesDemoState extends State { Future _prefs = SharedPreferences.getInstance(); Future _counter; - Future _incrementCounter() async { + Future _incrementCounter() async { final SharedPreferences prefs = await _prefs; final int counter = (prefs.getInt('counter') ?? 0) + 1; diff --git a/packages/url_launcher/example/lib/main.dart b/packages/url_launcher/example/lib/main.dart index d29aaa35342d..f330bc56a3f2 100644 --- a/packages/url_launcher/example/lib/main.dart +++ b/packages/url_launcher/example/lib/main.dart @@ -33,9 +33,9 @@ class MyHomePage extends StatefulWidget { } class _MyHomePageState extends State { - Future _launched; + Future _launched; - Future _launchInBrowser(String url) async { + Future _launchInBrowser(String url) async { if (await canLaunch(url)) { await launch(url, forceSafariVC: false, forceWebView: false); } else { @@ -43,7 +43,7 @@ class _MyHomePageState extends State { } } - Future _launchInWebViewOrVC(String url) async { + Future _launchInWebViewOrVC(String url) async { if (await canLaunch(url)) { await launch(url, forceSafariVC: true, forceWebView: true); } else { @@ -51,7 +51,7 @@ class _MyHomePageState extends State { } } - Future _launchInWebViewWithJavaScript(String url) async { + Future _launchInWebViewWithJavaScript(String url) async { if (await canLaunch(url)) { await launch( url, @@ -64,7 +64,7 @@ class _MyHomePageState extends State { } } - Widget _launchStatus(BuildContext context, AsyncSnapshot snapshot) { + Widget _launchStatus(BuildContext context, AsyncSnapshot snapshot) { if (snapshot.hasError) { return Text('Error: ${snapshot.error}'); } else { @@ -108,7 +108,7 @@ class _MyHomePageState extends State { child: const Text('Launch in app(JavaScript ON)'), ), const Padding(padding: EdgeInsets.all(16.0)), - FutureBuilder(future: _launched, builder: _launchStatus), + FutureBuilder(future: _launched, builder: _launchStatus), ], ), ), diff --git a/packages/webview_flutter/test/webview_flutter_test.dart b/packages/webview_flutter/test/webview_flutter_test.dart index 9768b26fa190..7a586b2c5533 100644 --- a/packages/webview_flutter/test/webview_flutter_test.dart +++ b/packages/webview_flutter/test/webview_flutter_test.dart @@ -122,7 +122,7 @@ class FakePlatformWebView { switch (call.method) { case 'loadUrl': lastUrlLoaded = call.arguments; - return Future.sync(() => null); + return Future.sync(() {}); case 'updateSettings': if (call.arguments['jsMode'] == null) { break; @@ -130,7 +130,7 @@ class FakePlatformWebView { javaScriptMode = JavaScriptMode.values[call.arguments['jsMode']]; break; } - return Future.sync(() => null); + return Future.sync(() {}); } } @@ -148,7 +148,7 @@ class _FakePlatformViewsController { ); return Future.sync(() => 1); default: - return Future.sync(() => null); + return Future.sync(() {}); } }