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

Commit

Permalink
enable lint prefer_void_to_null
Browse files Browse the repository at this point in the history
  • Loading branch information
a14n committed Oct 17, 2018
1 parent 41824d8 commit 866e3cd
Show file tree
Hide file tree
Showing 32 changed files with 118 additions and 121 deletions.
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions packages/android_alarm_manager/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:flutter/widgets.dart';
final FirebaseAuth firebaseAuth = FirebaseAuth.instance;
FirebaseUser firebaseUser;

Future<Null> ensureFirebaseUser() async {
Future<void> ensureFirebaseUser() async {
if (firebaseUser == null) {
firebaseUser = await firebaseAuth.currentUser();
if (firebaseUser == null) {
Expand Down Expand Up @@ -67,7 +67,7 @@ void printOneShot() {
printHelloMessage("Hello, once!");
}

Future<Null> main() async {
Future<void> main() async {
final int helloAlarmID = 0;
final int goodbyeAlarmID = 1;
final int oneShotID = 2;
Expand Down
2 changes: 1 addition & 1 deletion packages/android_intent/lib/android_intent.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Null> launch() async {
Future<void> launch() async {
assert(_platform.isAndroid);
final Map<String, dynamic> args = <String, dynamic>{'action': action};
if (category != null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/battery/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: const Icon(Icons.battery_unknown),
onPressed: () async {
final int batteryLevel = await _battery.batteryLevel;
showDialog<Null>(
showDialog<void>(
context: context,
builder: (_) => AlertDialog(
content: Text('Battery: $batteryLevel%'),
Expand Down
2 changes: 1 addition & 1 deletion packages/camera/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class CameraApp extends StatelessWidget {

List<CameraDescription> cameras;

Future<Null> main() async {
Future<void> main() async {
// Fetch the available cameras before initializing the app.
try {
cameras = await availableCameras();
Expand Down
37 changes: 17 additions & 20 deletions packages/camera/lib/camera.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,17 @@ class CameraController extends ValueNotifier<CameraValue> {
int _textureId;
bool _isDisposed = false;
StreamSubscription<dynamic> _eventSubscription;
Completer<Null> _creatingCompleter;
Completer<void> _creatingCompleter;

/// Initializes the camera on the device.
///
/// Throws a [CameraException] if the initialization fails.
Future<Null> initialize() async {
Future<void> initialize() async {
if (_isDisposed) {
return Future<Null>.value(null);
return Future<void>.value();
}
try {
_creatingCompleter = Completer<Null>();
_creatingCompleter = Completer<void>();
final Map<dynamic, dynamic> reply = await _channel.invokeMethod(
'initialize',
<String, dynamic>{
Expand All @@ -218,7 +218,7 @@ class CameraController extends ValueNotifier<CameraValue> {
EventChannel('flutter.io/cameraPlugin/cameraEvents$_textureId')
.receiveBroadcastStream()
.listen(_listener);
_creatingCompleter.complete(null);
_creatingCompleter.complete();
return _creatingCompleter.future;
}

Expand Down Expand Up @@ -250,7 +250,7 @@ class CameraController extends ValueNotifier<CameraValue> {
/// The file can be read as this function returns.
///
/// Throws a [CameraException] if the capture fails.
Future<Null> takePicture(String path) async {
Future<void> takePicture(String path) async {
if (!value.isInitialized || _isDisposed) {
throw CameraException(
'Uninitialized CameraController.',
Expand Down Expand Up @@ -286,7 +286,7 @@ class CameraController extends ValueNotifier<CameraValue> {
/// The file can be read as soon as [stopVideoRecording] returns.
///
/// Throws a [CameraException] if the capture fails.
Future<Null> startVideoRecording(String filePath) async {
Future<void> startVideoRecording(String filePath) async {
if (!value.isInitialized || _isDisposed) {
throw CameraException(
'Uninitialized CameraController',
Expand All @@ -311,7 +311,7 @@ class CameraController extends ValueNotifier<CameraValue> {
}

/// Stop recording.
Future<Null> stopVideoRecording() async {
Future<void> stopVideoRecording() async {
if (!value.isInitialized || _isDisposed) {
throw CameraException(
'Uninitialized CameraController',
Expand All @@ -337,22 +337,19 @@ class CameraController extends ValueNotifier<CameraValue> {

/// Releases the resources of this camera.
@override
Future<Null> dispose() async {
Future<void> dispose() async {
if (_isDisposed) {
return Future<Null>.value(null);
return;
}
_isDisposed = true;
super.dispose();
if (_creatingCompleter == null) {
return Future<Null>.value(null);
} else {
return _creatingCompleter.future.then((_) async {
await _channel.invokeMethod(
'dispose',
<String, dynamic>{'textureId': _textureId},
);
await _eventSubscription?.cancel();
});
if (_creatingCompleter != null) {
await _creatingCompleter.future;
await _channel.invokeMethod(
'dispose',
<String, dynamic>{'textureId': _textureId},
);
await _eventSubscription?.cancel();
}
}
}
2 changes: 1 addition & 1 deletion packages/cloud_firestore/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class MyHomePage extends StatelessWidget {
final Firestore firestore;
CollectionReference get messages => firestore.collection('messages');

Future<Null> _addMessage() async {
Future<void> _addMessage() async {
final DocumentReference document = messages.document();
document.setData(<String, dynamic>{
'message': 'Hello world!',
Expand Down
4 changes: 2 additions & 2 deletions packages/cloud_firestore/lib/src/write_batch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Null> commit() async {
Future<void> commit() async {
if (!_committed) {
_committed = true;
await Future.wait<dynamic>(_actions);
return await Firestore.channel.invokeMethod(
await Firestore.channel.invokeMethod(
'WriteBatch#commit', <String, dynamic>{'handle': await _handle});
} else {
throw StateError("This batch has already been committed.");
Expand Down
10 changes: 5 additions & 5 deletions packages/cloud_firestore/test/cloud_firestore_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<Null>.delayed(Duration.zero);
await Future<void>.delayed(Duration.zero);
expect(log, <Matcher>[
isMethodCall(
'Query#addSnapshotListener',
Expand All @@ -305,7 +305,7 @@ void main() {
.snapshots()
.listen((QuerySnapshot querySnapshot) {});
subscription.cancel();
await Future<Null>.delayed(Duration.zero);
await Future<void>.delayed(Duration.zero);
expect(
log,
equals(<Matcher>[
Expand Down Expand Up @@ -336,7 +336,7 @@ void main() {
.snapshots()
.listen((QuerySnapshot querySnapshot) {});
subscription.cancel();
await Future<Null>.delayed(Duration.zero);
await Future<void>.delayed(Duration.zero);
expect(
log,
equals(<Matcher>[
Expand Down Expand Up @@ -367,7 +367,7 @@ void main() {
.snapshots()
.listen((QuerySnapshot querySnapshot) {});
subscription.cancel();
await Future<Null>.delayed(Duration.zero);
await Future<void>.delayed(Duration.zero);
expect(
log,
equals(<Matcher>[
Expand Down Expand Up @@ -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<Null>.delayed(Duration.zero);
await Future<void>.delayed(Duration.zero);
expect(
log,
<Matcher>[
Expand Down
2 changes: 1 addition & 1 deletion packages/connectivity/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class _MyHomePageState extends State<MyHomePage> {
}

// Platform messages are asynchronous, so we initialize in an async method.
Future<Null> initConnectivity() async {
Future<void> initConnectivity() async {
String connectionStatus;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/device_info/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class _MyAppState extends State<MyApp> {
initPlatformState();
}

Future<Null> initPlatformState() async {
Future<void> initPlatformState() async {
Map<String, dynamic> deviceData;

try {
Expand Down
2 changes: 1 addition & 1 deletion packages/firebase_admob/lib/firebase_admob.dart
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ class FirebaseAdMob {
}
}

return Future<Null>(null);
return Future<dynamic>.value(null);
}
}

Expand Down
16 changes: 8 additions & 8 deletions packages/firebase_analytics/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class _MyHomePageState extends State<MyHomePage> {
});
}

Future<Null> _sendAnalyticsEvent() async {
Future<void> _sendAnalyticsEvent() async {
await analytics.logEvent(
name: 'test_event',
parameters: <String, dynamic>{
Expand All @@ -75,41 +75,41 @@ class _MyHomePageState extends State<MyHomePage> {
setMessage('logEvent succeeded');
}

Future<Null> _testSetUserId() async {
Future<void> _testSetUserId() async {
await analytics.setUserId('some-user');
setMessage('setUserId succeeded');
}

Future<Null> _testSetCurrentScreen() async {
Future<void> _testSetCurrentScreen() async {
await analytics.setCurrentScreen(
screenName: 'Analytics Demo',
screenClassOverride: 'AnalyticsDemo',
);
setMessage('setCurrentScreen succeeded');
}

Future<Null> _testSetAnalyticsCollectionEnabled() async {
Future<void> _testSetAnalyticsCollectionEnabled() async {
await analytics.android?.setAnalyticsCollectionEnabled(false);
await analytics.android?.setAnalyticsCollectionEnabled(true);
setMessage('setAnalyticsCollectionEnabled succeeded');
}

Future<Null> _testSetMinimumSessionDuration() async {
Future<void> _testSetMinimumSessionDuration() async {
await analytics.android?.setMinimumSessionDuration(20000);
setMessage('setMinimumSessionDuration succeeded');
}

Future<Null> _testSetSessionTimeoutDuration() async {
Future<void> _testSetSessionTimeoutDuration() async {
await analytics.android?.setSessionTimeoutDuration(2000000);
setMessage('setSessionTimeoutDuration succeeded');
}

Future<Null> _testSetUserProperty() async {
Future<void> _testSetUserProperty() async {
await analytics.setUserProperty(name: 'regular', value: 'indeed');
setMessage('setUserProperty succeeded');
}

Future<Null> _testAllEventTypes() async {
Future<void> _testAllEventTypes() async {
await analytics.logAddPaymentInfo();
await analytics.logAddToCart(
currency: 'USD',
Expand Down
Loading

0 comments on commit 866e3cd

Please sign in to comment.