Add `unawaited_futures` (#1148)

pull/1149/head
Brett Morgan 2 years ago committed by GitHub
parent 802026f4ea
commit f998c9577e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -167,7 +167,7 @@ class Contents extends StatelessWidget {
// a browser.
final url = Uri.parse('https://flutter.dev/docs');
if (await launcher.canLaunchUrl(url)) {
launcher.launchUrl(url);
await launcher.launchUrl(url);
}
},
child: const Text('Open Flutter Docs'),

@ -97,7 +97,7 @@ class _MyHomePageState extends State<MyHomePage> {
// a browser.
final url = Uri.parse('https://flutter.dev/docs');
if (await launcher.canLaunchUrl(url)) {
launcher.launchUrl(url);
await launcher.launchUrl(url);
}
},
child: const Text('Open Flutter Docs'),

@ -166,7 +166,7 @@ class Contents extends StatelessWidget {
// a browser.
final url = Uri.parse('https://flutter.dev/docs');
if (await launcher.canLaunchUrl(url)) {
launcher.launchUrl(url);
await launcher.launchUrl(url);
}
},
child: const Text('Open Flutter Docs'),

@ -16,4 +16,5 @@ linter:
package_prefixed_library_names: true
test_types_in_equals: true
throw_in_finally: true
unawaited_futures: true
unnecessary_statements: true

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
@ -86,10 +87,10 @@ class Unsplash {
});
_log.info('GET ${photo.links!.downloadLocation}');
http.get(Uri.parse(photo.links!.downloadLocation!), headers: {
unawaited(http.get(Uri.parse(photo.links!.downloadLocation!), headers: {
'Accept-Version': 'v1',
'Authorization': 'Client-ID $_accessKey',
});
}));
return futureBytes;
}

@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
@ -86,10 +87,10 @@ class Unsplash {
});
_log.info('GET ${photo.links!.downloadLocation}');
http.get(Uri.parse(photo.links!.downloadLocation!), headers: {
unawaited(http.get(Uri.parse(photo.links!.downloadLocation!), headers: {
'Accept-Version': 'v1',
'Authorization': 'Client-ID $_accessKey',
});
}));
return futureBytes;
}

@ -144,7 +144,7 @@ class ProfilesStore extends ChangeNotifier {
/// Save file to disk if path was provided.
if (savePath != null) {
file.saveTo(savePath);
await file.saveTo(savePath);
return true;
}

@ -104,7 +104,7 @@ class SavedLintsPage extends StatelessWidget {
break;
case 'Delete':
profilesStore.deleteProfile(profile);
await profilesStore.deleteProfile(profile);
break;
default:
}

@ -13,7 +13,7 @@ class HiveService {
List<T> existingProducts = await getBoxes(boxName);
if (!existingProducts.contains(item)) {
openBox.add(item);
await openBox.add(item);
return true;
}
return false;
@ -28,7 +28,7 @@ class HiveService {
for (var item in items) {
if (!existingProducts.contains(item)) {
openBox.add(item);
await openBox.add(item);
}
}
}
@ -42,7 +42,7 @@ class HiveService {
for (var box in boxes) {
if (box == item) {
openBox.deleteAt(boxes.indexOf(item));
await openBox.deleteAt(boxes.indexOf(item));
}
}
}
@ -56,7 +56,7 @@ class HiveService {
for (var box in boxes) {
if (box == item) {
openBox.putAt(boxes.indexOf(item), newItem);
await openBox.putAt(boxes.indexOf(item), newItem);
}
}
}

@ -139,7 +139,7 @@ class _LintExpansionTileState extends State<LintExpansionTile> {
},
);
if (destinationProfileType == ProfileType.newProfile) {
showDialog<String>(
await showDialog<String>(
context: context,
builder: (context) {
return _NewProfileDialog(rule: rule);
@ -147,7 +147,7 @@ class _LintExpansionTileState extends State<LintExpansionTile> {
);
} else if (destinationProfileType ==
ProfileType.existingProfile) {
showDialog<String>(
await showDialog<String>(
context: context,
builder: (context) {
return _ExistingProfileDialog(rule: rule);

@ -79,7 +79,7 @@ class _BookstoreNavigatorState extends State<BookstoreNavigator> {
var signedIn = await authState.signIn(
credentials.username, credentials.password);
if (signedIn) {
routeState.go('/books/popular');
await routeState.go('/books/popular');
}
},
),

@ -372,7 +372,7 @@ class _ControlledAnimationState<T> extends State<ControlledAnimation>
await Future.delayed(widget.delay!);
}
_waitForDelay = false;
executeInstruction();
await executeInstruction();
}
@override
@ -391,23 +391,23 @@ class _ControlledAnimationState<T> extends State<ControlledAnimation>
_controller.stop();
}
if (widget.playback == Playback.PLAY_FORWARD) {
_controller.forward();
await _controller.forward();
}
if (widget.playback == Playback.PLAY_REVERSE) {
_controller.reverse();
await _controller.reverse();
}
if (widget.playback == Playback.START_OVER_FORWARD) {
_controller.forward(from: 0.0);
await _controller.forward(from: 0.0);
}
if (widget.playback == Playback.START_OVER_REVERSE) {
_controller.reverse(from: 1.0);
await _controller.reverse(from: 1.0);
}
if (widget.playback == Playback.LOOP) {
_controller.repeat();
await _controller.repeat();
}
if (widget.playback == Playback.MIRROR && !_isCurrentlyMirroring) {
_isCurrentlyMirroring = true;
_controller.repeat(reverse: true);
await _controller.repeat(reverse: true);
}
if (widget.playback != Playback.MIRROR) {

Loading…
Cancel
Save