mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 22:09:06 +00:00
Add unawaited_futures (#1148)
This commit is contained in:
@@ -167,7 +167,7 @@ class Contents extends StatelessWidget {
|
|||||||
// a browser.
|
// a browser.
|
||||||
final url = Uri.parse('https://flutter.dev/docs');
|
final url = Uri.parse('https://flutter.dev/docs');
|
||||||
if (await launcher.canLaunchUrl(url)) {
|
if (await launcher.canLaunchUrl(url)) {
|
||||||
launcher.launchUrl(url);
|
await launcher.launchUrl(url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Text('Open Flutter Docs'),
|
child: const Text('Open Flutter Docs'),
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ class _MyHomePageState extends State<MyHomePage> {
|
|||||||
// a browser.
|
// a browser.
|
||||||
final url = Uri.parse('https://flutter.dev/docs');
|
final url = Uri.parse('https://flutter.dev/docs');
|
||||||
if (await launcher.canLaunchUrl(url)) {
|
if (await launcher.canLaunchUrl(url)) {
|
||||||
launcher.launchUrl(url);
|
await launcher.launchUrl(url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Text('Open Flutter Docs'),
|
child: const Text('Open Flutter Docs'),
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ class Contents extends StatelessWidget {
|
|||||||
// a browser.
|
// a browser.
|
||||||
final url = Uri.parse('https://flutter.dev/docs');
|
final url = Uri.parse('https://flutter.dev/docs');
|
||||||
if (await launcher.canLaunchUrl(url)) {
|
if (await launcher.canLaunchUrl(url)) {
|
||||||
launcher.launchUrl(url);
|
await launcher.launchUrl(url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: const Text('Open Flutter Docs'),
|
child: const Text('Open Flutter Docs'),
|
||||||
|
|||||||
@@ -16,4 +16,5 @@ linter:
|
|||||||
package_prefixed_library_names: true
|
package_prefixed_library_names: true
|
||||||
test_types_in_equals: true
|
test_types_in_equals: true
|
||||||
throw_in_finally: true
|
throw_in_finally: true
|
||||||
|
unawaited_futures: true
|
||||||
unnecessary_statements: true
|
unnecessary_statements: true
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
@@ -86,10 +87,10 @@ class Unsplash {
|
|||||||
});
|
});
|
||||||
|
|
||||||
_log.info('GET ${photo.links!.downloadLocation}');
|
_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',
|
'Accept-Version': 'v1',
|
||||||
'Authorization': 'Client-ID $_accessKey',
|
'Authorization': 'Client-ID $_accessKey',
|
||||||
});
|
}));
|
||||||
|
|
||||||
return futureBytes;
|
return futureBytes;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// Use of this source code is governed by a BSD-style license that can be
|
// Use of this source code is governed by a BSD-style license that can be
|
||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
|
|
||||||
|
import 'dart:async';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
|
||||||
@@ -86,10 +87,10 @@ class Unsplash {
|
|||||||
});
|
});
|
||||||
|
|
||||||
_log.info('GET ${photo.links!.downloadLocation}');
|
_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',
|
'Accept-Version': 'v1',
|
||||||
'Authorization': 'Client-ID $_accessKey',
|
'Authorization': 'Client-ID $_accessKey',
|
||||||
});
|
}));
|
||||||
|
|
||||||
return futureBytes;
|
return futureBytes;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ class ProfilesStore extends ChangeNotifier {
|
|||||||
|
|
||||||
/// Save file to disk if path was provided.
|
/// Save file to disk if path was provided.
|
||||||
if (savePath != null) {
|
if (savePath != null) {
|
||||||
file.saveTo(savePath);
|
await file.saveTo(savePath);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ class SavedLintsPage extends StatelessWidget {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
case 'Delete':
|
case 'Delete':
|
||||||
profilesStore.deleteProfile(profile);
|
await profilesStore.deleteProfile(profile);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class HiveService {
|
|||||||
List<T> existingProducts = await getBoxes(boxName);
|
List<T> existingProducts = await getBoxes(boxName);
|
||||||
|
|
||||||
if (!existingProducts.contains(item)) {
|
if (!existingProducts.contains(item)) {
|
||||||
openBox.add(item);
|
await openBox.add(item);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -28,7 +28,7 @@ class HiveService {
|
|||||||
|
|
||||||
for (var item in items) {
|
for (var item in items) {
|
||||||
if (!existingProducts.contains(item)) {
|
if (!existingProducts.contains(item)) {
|
||||||
openBox.add(item);
|
await openBox.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ class HiveService {
|
|||||||
|
|
||||||
for (var box in boxes) {
|
for (var box in boxes) {
|
||||||
if (box == item) {
|
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) {
|
for (var box in boxes) {
|
||||||
if (box == item) {
|
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) {
|
if (destinationProfileType == ProfileType.newProfile) {
|
||||||
showDialog<String>(
|
await showDialog<String>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return _NewProfileDialog(rule: rule);
|
return _NewProfileDialog(rule: rule);
|
||||||
@@ -147,7 +147,7 @@ class _LintExpansionTileState extends State<LintExpansionTile> {
|
|||||||
);
|
);
|
||||||
} else if (destinationProfileType ==
|
} else if (destinationProfileType ==
|
||||||
ProfileType.existingProfile) {
|
ProfileType.existingProfile) {
|
||||||
showDialog<String>(
|
await showDialog<String>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return _ExistingProfileDialog(rule: rule);
|
return _ExistingProfileDialog(rule: rule);
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class _BookstoreNavigatorState extends State<BookstoreNavigator> {
|
|||||||
var signedIn = await authState.signIn(
|
var signedIn = await authState.signIn(
|
||||||
credentials.username, credentials.password);
|
credentials.username, credentials.password);
|
||||||
if (signedIn) {
|
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!);
|
await Future.delayed(widget.delay!);
|
||||||
}
|
}
|
||||||
_waitForDelay = false;
|
_waitForDelay = false;
|
||||||
executeInstruction();
|
await executeInstruction();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -391,23 +391,23 @@ class _ControlledAnimationState<T> extends State<ControlledAnimation>
|
|||||||
_controller.stop();
|
_controller.stop();
|
||||||
}
|
}
|
||||||
if (widget.playback == Playback.PLAY_FORWARD) {
|
if (widget.playback == Playback.PLAY_FORWARD) {
|
||||||
_controller.forward();
|
await _controller.forward();
|
||||||
}
|
}
|
||||||
if (widget.playback == Playback.PLAY_REVERSE) {
|
if (widget.playback == Playback.PLAY_REVERSE) {
|
||||||
_controller.reverse();
|
await _controller.reverse();
|
||||||
}
|
}
|
||||||
if (widget.playback == Playback.START_OVER_FORWARD) {
|
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) {
|
if (widget.playback == Playback.START_OVER_REVERSE) {
|
||||||
_controller.reverse(from: 1.0);
|
await _controller.reverse(from: 1.0);
|
||||||
}
|
}
|
||||||
if (widget.playback == Playback.LOOP) {
|
if (widget.playback == Playback.LOOP) {
|
||||||
_controller.repeat();
|
await _controller.repeat();
|
||||||
}
|
}
|
||||||
if (widget.playback == Playback.MIRROR && !_isCurrentlyMirroring) {
|
if (widget.playback == Playback.MIRROR && !_isCurrentlyMirroring) {
|
||||||
_isCurrentlyMirroring = true;
|
_isCurrentlyMirroring = true;
|
||||||
_controller.repeat(reverse: true);
|
await _controller.repeat(reverse: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widget.playback != Playback.MIRROR) {
|
if (widget.playback != Playback.MIRROR) {
|
||||||
|
|||||||
Reference in New Issue
Block a user