Skip to content

Commit 9b02789

Browse files
Michael KlimushynPark Sung Min
authored andcommitted
[video_player] Fix pedantic lints (flutter#2321)
Fix pedantic lints. This fixes some potential race conditions in cases where futures within some video_player methods weren't being awaited correctly.
1 parent 34f4814 commit 9b02789

File tree

6 files changed

+13
-18
lines changed

6 files changed

+13
-18
lines changed

packages/video_player/video_player/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.10.4+1
2+
3+
* Fix pedantic lints. This fixes some potential race conditions in cases where
4+
futures within some video_player methods weren't being awaited correctly.
5+
16
## 0.10.4
27

38
* Port plugin code to use the federated Platform Interface, instead of a MethodChannel directly.

packages/video_player/video_player/analysis_options.yaml

Lines changed: 0 additions & 10 deletions
This file was deleted.

packages/video_player/video_player/example/test_driver/video_player_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'package:test/test.dart';
99
Future<void> main() async {
1010
final FlutterDriver driver = await FlutterDriver.connect();
1111
tearDownAll(() async {
12-
driver.close();
12+
await driver.close();
1313
});
1414

1515
//TODO(cyanglaz): Use TabBar tabs to navigate between pages after https://github.com/flutter/flutter/issues/16991 is fixed.

packages/video_player/video_player/lib/video_player.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -331,15 +331,15 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
331331
if (!value.initialized || _isDisposed) {
332332
return;
333333
}
334-
VideoPlayerPlatform.instance.setLooping(_textureId, value.isLooping);
334+
await VideoPlayerPlatform.instance.setLooping(_textureId, value.isLooping);
335335
}
336336

337337
Future<void> _applyPlayPause() async {
338338
if (!value.initialized || _isDisposed) {
339339
return;
340340
}
341341
if (value.isPlaying) {
342-
VideoPlayerPlatform.instance.play(_textureId);
342+
await VideoPlayerPlatform.instance.play(_textureId);
343343
_timer = Timer.periodic(
344344
const Duration(milliseconds: 500),
345345
(Timer timer) async {
@@ -358,15 +358,15 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
358358
await _applySpeed();
359359
} else {
360360
_timer?.cancel();
361-
VideoPlayerPlatform.instance.pause(_textureId);
361+
await VideoPlayerPlatform.instance.pause(_textureId);
362362
}
363363
}
364364

365365
Future<void> _applyVolume() async {
366366
if (!value.initialized || _isDisposed) {
367367
return;
368368
}
369-
VideoPlayerPlatform.instance.setVolume(_textureId, value.volume);
369+
await VideoPlayerPlatform.instance.setVolume(_textureId, value.volume);
370370
}
371371

372372
/// The position in the current video.
@@ -391,7 +391,7 @@ class VideoPlayerController extends ValueNotifier<VideoPlayerValue> {
391391
} else if (position < const Duration()) {
392392
position = const Duration();
393393
}
394-
VideoPlayerPlatform.instance.seekTo(_textureId, position);
394+
await VideoPlayerPlatform.instance.seekTo(_textureId, position);
395395
value = value.copyWith(position: position);
396396
}
397397

packages/video_player/video_player/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: video_player
22
description: Flutter plugin for displaying inline video with other Flutter
33
widgets on Android and iOS.
44
author: Flutter Team <flutter-dev@googlegroups.com>
5-
version: 0.10.4
5+
version: 0.10.4+1
66
homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player
77

88
flutter:

packages/video_player/video_player/test/video_player_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void main() {
172172
);
173173
expect(controller.textureId, isNull);
174174
expect(await controller.position, const Duration(seconds: 0));
175-
controller.initialize();
175+
await controller.initialize();
176176

177177
await controller.dispose();
178178

0 commit comments

Comments
 (0)