From de5292b99ef7a4f37f0cbe20669c9112f201eaa6 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 19 Feb 2021 13:24:28 -0800 Subject: [PATCH 1/7] [video_player_platform_interface] null-safe preview version. --- .../CHANGELOG.md | 26 ++--- .../pubspec.yaml | 9 +- .../method_channel_video_player_test.dart | 110 +++++++----------- 3 files changed, 53 insertions(+), 92 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/CHANGELOG.md b/packages/video_player/video_player_platform_interface/CHANGELOG.md index 7b223f4d958c..d0c59bd05023 100644 --- a/packages/video_player/video_player_platform_interface/CHANGELOG.md +++ b/packages/video_player/video_player_platform_interface/CHANGELOG.md @@ -1,27 +1,15 @@ -## 4.0.0-nullsafety.1 +## 4.0.0 +* **Breaking Changes**: + * Migrate to null-safety + * Update to latest Pigeon. This includes a breaking change to how the test logic is exposed. * Add note about the `mixWithOthers` option being ignored on the web. - -## 4.0.0-nullsafety.0 - -* Update to latest Pigeon. - This includes a breaking change to how the test logic is exposed. - -## 3.0.0-nullsafety.3 - -* `messages.dart` sets Dart `2.12`. - -## 3.0.0-nullsafety.2 - -* Bump Dart SDK to support null safety. - -## 3.0.0-nullsafety.1 - * Make DataSource's `uri` parameter nullable. +* `messages.dart` sets Dart `2.12`. -## 3.0.0-nullsafety +## 3.0.0 -* Migrate to null safety. +* Version 3 only was published as nullsafety "previews". ## 2.2.1 diff --git a/packages/video_player/video_player_platform_interface/pubspec.yaml b/packages/video_player/video_player_platform_interface/pubspec.yaml index ed16ea1033fa..d6ab94170a81 100644 --- a/packages/video_player/video_player_platform_interface/pubspec.yaml +++ b/packages/video_player/video_player_platform_interface/pubspec.yaml @@ -3,19 +3,18 @@ description: A common platform interface for the video_player plugin. homepage: https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_platform_interface # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 4.0.0-nullsafety.1 +version: 4.0.0 dependencies: flutter: sdk: flutter - meta: ^1.3.0-nullsafety.3 + meta: ^1.3.0 flutter_test: sdk: flutter dev_dependencies: - mockito: ^4.1.1 - pedantic: ^1.10.0-nullsafety.1 + pedantic: ^1.10.0 environment: sdk: ">=2.12.0-0 <3.0.0" - flutter: ">=1.10.0" + flutter: ">=1.20.0" diff --git a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart index 669fd2839897..fae4b746bf05 100644 --- a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart +++ b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart @@ -2,14 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// TODO(egarciad): Remove once Mockito is migrated to null safety. -// @dart = 2.9 - import 'dart:ui'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import 'package:mockito/mockito.dart'; import 'package:video_player_platform_interface/messages.dart'; import 'package:video_player_platform_interface/method_channel_video_player.dart'; import 'package:video_player_platform_interface/test.dart'; @@ -17,13 +13,13 @@ import 'package:video_player_platform_interface/video_player_platform_interface. class _ApiLogger implements TestHostVideoPlayerApi { final List log = []; - TextureMessage textureMessage; - CreateMessage createMessage; - PositionMessage positionMessage; - LoopingMessage loopingMessage; - VolumeMessage volumeMessage; - PlaybackSpeedMessage playbackSpeedMessage; - MixWithOthersMessage mixWithOthersMessage; + TextureMessage? textureMessage; + CreateMessage? createMessage; + PositionMessage? positionMessage; + LoopingMessage? loopingMessage; + VolumeMessage? volumeMessage; + PlaybackSpeedMessage? playbackSpeedMessage; + MixWithOthersMessage? mixWithOthersMessage; @override TextureMessage create(CreateMessage arg) { @@ -101,28 +97,11 @@ void main() { expect(VideoPlayerPlatform.instance, isInstanceOf()); }); - - test('Cannot be implemented with `implements`', () { - expect(() { - VideoPlayerPlatform.instance = ImplementsVideoPlayerPlatform(); - }, throwsA(isInstanceOf())); - }); - - test('Can be mocked with `implements`', () { - final ImplementsVideoPlayerPlatform mock = - ImplementsVideoPlayerPlatform(); - when(mock.isMock).thenReturn(true); - VideoPlayerPlatform.instance = mock; - }); - - test('Can be extended', () { - VideoPlayerPlatform.instance = ExtendsVideoPlayerPlatform(); - }); }); group('$MethodChannelVideoPlayer', () { final MethodChannelVideoPlayer player = MethodChannelVideoPlayer(); - _ApiLogger log; + late _ApiLogger log; setUp(() { log = _ApiLogger(); @@ -140,108 +119,108 @@ void main() { test('dispose', () async { await player.dispose(1); expect(log.log.last, 'dispose'); - expect(log.textureMessage.textureId, 1); + expect(log.textureMessage?.textureId, 1); }); test('create with asset', () async { - final int textureId = await player.create(DataSource( + final int? textureId = await player.create(DataSource( sourceType: DataSourceType.asset, asset: 'someAsset', package: 'somePackage', )); expect(log.log.last, 'create'); - expect(log.createMessage.asset, 'someAsset'); - expect(log.createMessage.packageName, 'somePackage'); + expect(log.createMessage?.asset, 'someAsset'); + expect(log.createMessage?.packageName, 'somePackage'); expect(textureId, 3); }); test('create with network', () async { - final int textureId = await player.create(DataSource( + final int? textureId = await player.create(DataSource( sourceType: DataSourceType.network, uri: 'someUri', formatHint: VideoFormat.dash, )); expect(log.log.last, 'create'); - expect(log.createMessage.uri, 'someUri'); - expect(log.createMessage.formatHint, 'dash'); + expect(log.createMessage?.uri, 'someUri'); + expect(log.createMessage?.formatHint, 'dash'); expect(textureId, 3); }); test('create with file', () async { - final int textureId = await player.create(DataSource( + final int? textureId = await player.create(DataSource( sourceType: DataSourceType.file, uri: 'someUri', )); expect(log.log.last, 'create'); - expect(log.createMessage.uri, 'someUri'); + expect(log.createMessage?.uri, 'someUri'); expect(textureId, 3); }); test('setLooping', () async { await player.setLooping(1, true); expect(log.log.last, 'setLooping'); - expect(log.loopingMessage.textureId, 1); - expect(log.loopingMessage.isLooping, true); + expect(log.loopingMessage?.textureId, 1); + expect(log.loopingMessage?.isLooping, true); }); test('play', () async { await player.play(1); expect(log.log.last, 'play'); - expect(log.textureMessage.textureId, 1); + expect(log.textureMessage?.textureId, 1); }); test('pause', () async { await player.pause(1); expect(log.log.last, 'pause'); - expect(log.textureMessage.textureId, 1); + expect(log.textureMessage?.textureId, 1); }); test('setMixWithOthers', () async { await player.setMixWithOthers(true); expect(log.log.last, 'setMixWithOthers'); - expect(log.mixWithOthersMessage.mixWithOthers, true); + expect(log.mixWithOthersMessage?.mixWithOthers, true); await player.setMixWithOthers(false); expect(log.log.last, 'setMixWithOthers'); - expect(log.mixWithOthersMessage.mixWithOthers, false); + expect(log.mixWithOthersMessage?.mixWithOthers, false); }); test('setVolume', () async { await player.setVolume(1, 0.7); expect(log.log.last, 'setVolume'); - expect(log.volumeMessage.textureId, 1); - expect(log.volumeMessage.volume, 0.7); + expect(log.volumeMessage?.textureId, 1); + expect(log.volumeMessage?.volume, 0.7); }); test('setPlaybackSpeed', () async { await player.setPlaybackSpeed(1, 1.5); expect(log.log.last, 'setPlaybackSpeed'); - expect(log.playbackSpeedMessage.textureId, 1); - expect(log.playbackSpeedMessage.speed, 1.5); + expect(log.playbackSpeedMessage?.textureId, 1); + expect(log.playbackSpeedMessage?.speed, 1.5); }); test('seekTo', () async { await player.seekTo(1, const Duration(milliseconds: 12345)); expect(log.log.last, 'seekTo'); - expect(log.positionMessage.textureId, 1); - expect(log.positionMessage.position, 12345); + expect(log.positionMessage?.textureId, 1); + expect(log.positionMessage?.position, 12345); }); test('getPosition', () async { final Duration position = await player.getPosition(1); expect(log.log.last, 'position'); - expect(log.textureMessage.textureId, 1); + expect(log.textureMessage?.textureId, 1); expect(position, const Duration(milliseconds: 234)); }); test('videoEventsFor', () async { - ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler( + ServicesBinding.instance?.defaultBinaryMessenger.setMockMessageHandler( "flutter.io/videoPlayer/videoEvents123", - (ByteData message) async { + (ByteData? message) async { final MethodCall methodCall = const StandardMethodCodec().decodeMethodCall(message); if (methodCall.method == 'listen') { - await ServicesBinding.instance.defaultBinaryMessenger + await ServicesBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( "flutter.io/videoPlayer/videoEvents123", const StandardMethodCodec() @@ -251,18 +230,18 @@ void main() { 'width': 1920, 'height': 1080, }), - (ByteData data) {}); + (ByteData? data) {}); - await ServicesBinding.instance.defaultBinaryMessenger + await ServicesBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( "flutter.io/videoPlayer/videoEvents123", const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'completed', }), - (ByteData data) {}); + (ByteData? data) {}); - await ServicesBinding.instance.defaultBinaryMessenger + await ServicesBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( "flutter.io/videoPlayer/videoEvents123", const StandardMethodCodec() @@ -273,25 +252,25 @@ void main() { [1235, 4000], ], }), - (ByteData data) {}); + (ByteData? data) {}); - await ServicesBinding.instance.defaultBinaryMessenger + await ServicesBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( "flutter.io/videoPlayer/videoEvents123", const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'bufferingStart', }), - (ByteData data) {}); + (ByteData? data) {}); - await ServicesBinding.instance.defaultBinaryMessenger + await ServicesBinding.instance?.defaultBinaryMessenger .handlePlatformMessage( "flutter.io/videoPlayer/videoEvents123", const StandardMethodCodec() .encodeSuccessEnvelope({ 'event': 'bufferingEnd', }), - (ByteData data) {}); + (ByteData? data) {}); return const StandardMethodCodec().encodeSuccessEnvelope(null); } else if (methodCall.method == 'cancel') { @@ -328,8 +307,3 @@ void main() { }); }); } - -class ImplementsVideoPlayerPlatform extends Mock - implements VideoPlayerPlatform {} - -class ExtendsVideoPlayerPlatform extends VideoPlayerPlatform {} From 4bd988dba3593197714d5125bed4db8df3d91691 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 19 Feb 2021 14:18:48 -0800 Subject: [PATCH 2/7] Patch/ignore breaking tests in sound null-mode. --- .../test/method_channel_video_player_test.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart index fae4b746bf05..b97f49d9a12e 100644 --- a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart +++ b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart @@ -61,7 +61,10 @@ class _ApiLogger implements TestHostVideoPlayerApi { PositionMessage position(TextureMessage arg) { log.add('position'); textureMessage = arg; - return PositionMessage()..position = 234; + return PositionMessage() + ..position = 234 + // TODO(plugins): Only needed until flutter/flutter#76405 lands, and pigeons are regenerated. + ..textureId = arg.textureId; } @override @@ -132,7 +135,7 @@ void main() { expect(log.createMessage?.asset, 'someAsset'); expect(log.createMessage?.packageName, 'somePackage'); expect(textureId, 3); - }); + }, skip: "Until flutter/flutter#76405 lands, and pigeons are regenerated."); test('create with network', () async { final int? textureId = await player.create(DataSource( @@ -144,7 +147,7 @@ void main() { expect(log.createMessage?.uri, 'someUri'); expect(log.createMessage?.formatHint, 'dash'); expect(textureId, 3); - }); + }, skip: "Until flutter/flutter#76405 lands, and pigeons are regenerated."); test('create with file', () async { final int? textureId = await player.create(DataSource( @@ -154,7 +157,7 @@ void main() { expect(log.log.last, 'create'); expect(log.createMessage?.uri, 'someUri'); expect(textureId, 3); - }); + }, skip: "Until flutter/flutter#76405 lands, and pigeons are regenerated."); test('setLooping', () async { await player.setLooping(1, true); From a55a9766d6053757f079186e27ce2b1b9150126d Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Fri, 19 Feb 2021 15:01:55 -0800 Subject: [PATCH 3/7] Bump sdk to version with stable null-safety. --- .../video_player/video_player_platform_interface/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/video_player/video_player_platform_interface/pubspec.yaml b/packages/video_player/video_player_platform_interface/pubspec.yaml index d6ab94170a81..c85f483d041f 100644 --- a/packages/video_player/video_player_platform_interface/pubspec.yaml +++ b/packages/video_player/video_player_platform_interface/pubspec.yaml @@ -16,5 +16,5 @@ dev_dependencies: pedantic: ^1.10.0 environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.12.0-259.9.beta <3.0.0" flutter: ">=1.20.0" From 74213fc43afcdd0db46d5589a4c8e11cb043155c Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Mon, 22 Feb 2021 11:52:12 -0800 Subject: [PATCH 4/7] Un-skip tests, and tweak generated file according to the next version of pigeon. --- .../video_player_platform_interface/lib/messages.dart | 9 +++++---- .../test/method_channel_video_player_test.dart | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/lib/messages.dart b/packages/video_player/video_player_platform_interface/lib/messages.dart index 3f2d78ef9ed5..a39726178ad6 100644 --- a/packages/video_player/video_player_platform_interface/lib/messages.dart +++ b/packages/video_player/video_player_platform_interface/lib/messages.dart @@ -40,10 +40,11 @@ class CreateMessage { static CreateMessage decode(Object message) { final Map pigeonMap = message as Map; return CreateMessage() - ..asset = pigeonMap['asset'] as String - ..uri = pigeonMap['uri'] as String - ..packageName = pigeonMap['packageName'] as String - ..formatHint = pigeonMap['formatHint'] as String; + // Modified manually until flutter/packages#292 lands + ..asset = pigeonMap['asset'] as String? + ..uri = pigeonMap['uri'] as String? + ..packageName = pigeonMap['packageName'] as String? + ..formatHint = pigeonMap['formatHint'] as String?; } } diff --git a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart index b97f49d9a12e..565331da9d21 100644 --- a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart +++ b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart @@ -135,7 +135,7 @@ void main() { expect(log.createMessage?.asset, 'someAsset'); expect(log.createMessage?.packageName, 'somePackage'); expect(textureId, 3); - }, skip: "Until flutter/flutter#76405 lands, and pigeons are regenerated."); + }); test('create with network', () async { final int? textureId = await player.create(DataSource( @@ -147,7 +147,7 @@ void main() { expect(log.createMessage?.uri, 'someUri'); expect(log.createMessage?.formatHint, 'dash'); expect(textureId, 3); - }, skip: "Until flutter/flutter#76405 lands, and pigeons are regenerated."); + }); test('create with file', () async { final int? textureId = await player.create(DataSource( @@ -157,7 +157,7 @@ void main() { expect(log.log.last, 'create'); expect(log.createMessage?.uri, 'someUri'); expect(textureId, 3); - }, skip: "Until flutter/flutter#76405 lands, and pigeons are regenerated."); + }); test('setLooping', () async { await player.setLooping(1, true); From d17b77b8cc21e9784c22be6a966fa756c241e6d6 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Mon, 22 Feb 2021 15:48:12 -0800 Subject: [PATCH 5/7] Update pigeon messages with latest pigeon --- .../lib/messages.dart | 136 ++++++++---------- .../lib/test.dart | 87 +++++------ 2 files changed, 91 insertions(+), 132 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/lib/messages.dart b/packages/video_player/video_player_platform_interface/lib/messages.dart index a39726178ad6..39fec04d3f74 100644 --- a/packages/video_player/video_player_platform_interface/lib/messages.dart +++ b/packages/video_player/video_player_platform_interface/lib/messages.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v0.1.19), do not edit directly. +// Autogenerated from Pigeon (v0.1.21), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import // @dart = 2.12 @@ -18,7 +18,8 @@ class TextureMessage { static TextureMessage decode(Object message) { final Map pigeonMap = message as Map; - return TextureMessage()..textureId = pigeonMap['textureId'] as int; + return TextureMessage() + ..textureId = pigeonMap['textureId'] as int?; } } @@ -40,7 +41,6 @@ class CreateMessage { static CreateMessage decode(Object message) { final Map pigeonMap = message as Map; return CreateMessage() - // Modified manually until flutter/packages#292 lands ..asset = pigeonMap['asset'] as String? ..uri = pigeonMap['uri'] as String? ..packageName = pigeonMap['packageName'] as String? @@ -62,8 +62,8 @@ class LoopingMessage { static LoopingMessage decode(Object message) { final Map pigeonMap = message as Map; return LoopingMessage() - ..textureId = pigeonMap['textureId'] as int - ..isLooping = pigeonMap['isLooping'] as bool; + ..textureId = pigeonMap['textureId'] as int? + ..isLooping = pigeonMap['isLooping'] as bool?; } } @@ -81,8 +81,8 @@ class VolumeMessage { static VolumeMessage decode(Object message) { final Map pigeonMap = message as Map; return VolumeMessage() - ..textureId = pigeonMap['textureId'] as int - ..volume = pigeonMap['volume'] as double; + ..textureId = pigeonMap['textureId'] as int? + ..volume = pigeonMap['volume'] as double?; } } @@ -100,8 +100,8 @@ class PlaybackSpeedMessage { static PlaybackSpeedMessage decode(Object message) { final Map pigeonMap = message as Map; return PlaybackSpeedMessage() - ..textureId = pigeonMap['textureId'] as int - ..speed = pigeonMap['speed'] as double; + ..textureId = pigeonMap['textureId'] as int? + ..speed = pigeonMap['speed'] as double?; } } @@ -119,8 +119,8 @@ class PositionMessage { static PositionMessage decode(Object message) { final Map pigeonMap = message as Map; return PositionMessage() - ..textureId = pigeonMap['textureId'] as int - ..position = pigeonMap['position'] as int; + ..textureId = pigeonMap['textureId'] as int? + ..position = pigeonMap['position'] as int?; } } @@ -136,16 +136,15 @@ class MixWithOthersMessage { static MixWithOthersMessage decode(Object message) { final Map pigeonMap = message as Map; return MixWithOthersMessage() - ..mixWithOthers = pigeonMap['mixWithOthers'] as bool; + ..mixWithOthers = pigeonMap['mixWithOthers'] as bool?; } } class VideoPlayerApi { Future initialize() async { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); - final Map? replyMap = - await channel.send(null) as Map?; + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); + final Map? replyMap = await channel.send(null) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -153,8 +152,7 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = - replyMap['error'] as Map; + final Map error = replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -167,10 +165,9 @@ class VideoPlayerApi { Future create(CreateMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); - final Map? replyMap = - await channel.send(encoded) as Map?; + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + final Map? replyMap = await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -178,8 +175,7 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = - replyMap['error'] as Map; + final Map error = replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -192,10 +188,9 @@ class VideoPlayerApi { Future dispose(TextureMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); - final Map? replyMap = - await channel.send(encoded) as Map?; + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + final Map? replyMap = await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -203,8 +198,7 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = - replyMap['error'] as Map; + final Map error = replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -217,10 +211,9 @@ class VideoPlayerApi { Future setLooping(LoopingMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); - final Map? replyMap = - await channel.send(encoded) as Map?; + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); + final Map? replyMap = await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -228,8 +221,7 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = - replyMap['error'] as Map; + final Map error = replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -242,10 +234,9 @@ class VideoPlayerApi { Future setVolume(VolumeMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); - final Map? replyMap = - await channel.send(encoded) as Map?; + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); + final Map? replyMap = await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -253,8 +244,7 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = - replyMap['error'] as Map; + final Map error = replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -267,11 +257,9 @@ class VideoPlayerApi { Future setPlaybackSpeed(PlaybackSpeedMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', - StandardMessageCodec()); - final Map? replyMap = - await channel.send(encoded) as Map?; + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', StandardMessageCodec()); + final Map? replyMap = await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -279,8 +267,7 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = - replyMap['error'] as Map; + final Map error = replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -293,10 +280,9 @@ class VideoPlayerApi { Future play(TextureMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); - final Map? replyMap = - await channel.send(encoded) as Map?; + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + final Map? replyMap = await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -304,8 +290,7 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = - replyMap['error'] as Map; + final Map error = replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -318,10 +303,9 @@ class VideoPlayerApi { Future position(TextureMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); - final Map? replyMap = - await channel.send(encoded) as Map?; + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + final Map? replyMap = await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -329,8 +313,7 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = - replyMap['error'] as Map; + final Map error = replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -343,10 +326,9 @@ class VideoPlayerApi { Future seekTo(PositionMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); - final Map? replyMap = - await channel.send(encoded) as Map?; + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + final Map? replyMap = await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -354,8 +336,7 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = - replyMap['error'] as Map; + final Map error = replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -368,10 +349,9 @@ class VideoPlayerApi { Future pause(TextureMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); - final Map? replyMap = - await channel.send(encoded) as Map?; + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + final Map? replyMap = await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -379,8 +359,7 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = - replyMap['error'] as Map; + final Map error = replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -393,11 +372,9 @@ class VideoPlayerApi { Future setMixWithOthers(MixWithOthersMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', - StandardMessageCodec()); - final Map? replyMap = - await channel.send(encoded) as Map?; + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', StandardMessageCodec()); + final Map? replyMap = await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -405,8 +382,7 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = - replyMap['error'] as Map; + final Map error = replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, diff --git a/packages/video_player/video_player_platform_interface/lib/test.dart b/packages/video_player/video_player_platform_interface/lib/test.dart index 538e9526b111..c42092b97b3a 100644 --- a/packages/video_player/video_player_platform_interface/lib/test.dart +++ b/packages/video_player/video_player_platform_interface/lib/test.dart @@ -1,4 +1,4 @@ -// Autogenerated from Pigeon (v0.1.19), do not edit directly. +// Autogenerated from Pigeon (v0.1.21), do not edit directly. // See also: https://pub.dev/packages/pigeon // ignore_for_file: public_member_api_docs, non_constant_identifier_names, avoid_as, unused_import // @dart = 2.12 @@ -23,9 +23,8 @@ abstract class TestHostVideoPlayerApi { void setMixWithOthers(MixWithOthersMessage arg); static void setup(TestHostVideoPlayerApi? api) { { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.initialize', - StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { @@ -37,14 +36,13 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.create was null. Expected CreateMessage.'); + assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.create was null. Expected CreateMessage.'); final CreateMessage input = CreateMessage.decode(message!); final TextureMessage output = api.create(input); return {'result': output.encode()}; @@ -52,14 +50,13 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.dispose was null. Expected TextureMessage.'); + assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.dispose was null. Expected TextureMessage.'); final TextureMessage input = TextureMessage.decode(message!); api.dispose(input); return {}; @@ -67,15 +64,13 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setLooping', - StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.setLooping was null. Expected LoopingMessage.'); + assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.setLooping was null. Expected LoopingMessage.'); final LoopingMessage input = LoopingMessage.decode(message!); api.setLooping(input); return {}; @@ -83,15 +78,13 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setVolume', - StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.setVolume was null. Expected VolumeMessage.'); + assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.setVolume was null. Expected VolumeMessage.'); final VolumeMessage input = VolumeMessage.decode(message!); api.setVolume(input); return {}; @@ -99,31 +92,27 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', - StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed was null. Expected PlaybackSpeedMessage.'); - final PlaybackSpeedMessage input = - PlaybackSpeedMessage.decode(message!); + assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed was null. Expected PlaybackSpeedMessage.'); + final PlaybackSpeedMessage input = PlaybackSpeedMessage.decode(message!); api.setPlaybackSpeed(input); return {}; }); } } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.play was null. Expected TextureMessage.'); + assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.play was null. Expected TextureMessage.'); final TextureMessage input = TextureMessage.decode(message!); api.play(input); return {}; @@ -131,14 +120,13 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.position was null. Expected TextureMessage.'); + assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.position was null. Expected TextureMessage.'); final TextureMessage input = TextureMessage.decode(message!); final PositionMessage output = api.position(input); return {'result': output.encode()}; @@ -146,14 +134,13 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.seekTo was null. Expected PositionMessage.'); + assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.seekTo was null. Expected PositionMessage.'); final PositionMessage input = PositionMessage.decode(message!); api.seekTo(input); return {}; @@ -161,14 +148,13 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.pause was null. Expected TextureMessage.'); + assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.pause was null. Expected TextureMessage.'); final TextureMessage input = TextureMessage.decode(message!); api.pause(input); return {}; @@ -176,17 +162,14 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', - StandardMessageCodec()); + const BasicMessageChannel channel = + BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers was null. Expected MixWithOthersMessage.'); - final MixWithOthersMessage input = - MixWithOthersMessage.decode(message!); + assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers was null. Expected MixWithOthersMessage.'); + final MixWithOthersMessage input = MixWithOthersMessage.decode(message!); api.setMixWithOthers(input); return {}; }); From dd47afaeefa51ca625ad0a25762f9e5926b177e7 Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Mon, 22 Feb 2021 16:44:14 -0800 Subject: [PATCH 6/7] Un-modify test now that new pigeons have landed. --- .../test/method_channel_video_player_test.dart | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart index 565331da9d21..cbedcbd1bc24 100644 --- a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart +++ b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart @@ -62,9 +62,7 @@ class _ApiLogger implements TestHostVideoPlayerApi { log.add('position'); textureMessage = arg; return PositionMessage() - ..position = 234 - // TODO(plugins): Only needed until flutter/flutter#76405 lands, and pigeons are regenerated. - ..textureId = arg.textureId; + ..position = 234; } @override From 90d1c4810ad1c6f6bbf96c944d4b3e0293df95ac Mon Sep 17 00:00:00 2001 From: David Iglesias Teixeira Date: Mon, 22 Feb 2021 17:16:20 -0800 Subject: [PATCH 7/7] dartfmt -w . --- .../lib/messages.dart | 115 +++++++++++------- .../lib/test.dart | 85 +++++++------ .../method_channel_video_player_test.dart | 3 +- 3 files changed, 121 insertions(+), 82 deletions(-) diff --git a/packages/video_player/video_player_platform_interface/lib/messages.dart b/packages/video_player/video_player_platform_interface/lib/messages.dart index 39fec04d3f74..dc5237f2e151 100644 --- a/packages/video_player/video_player_platform_interface/lib/messages.dart +++ b/packages/video_player/video_player_platform_interface/lib/messages.dart @@ -18,8 +18,7 @@ class TextureMessage { static TextureMessage decode(Object message) { final Map pigeonMap = message as Map; - return TextureMessage() - ..textureId = pigeonMap['textureId'] as int?; + return TextureMessage()..textureId = pigeonMap['textureId'] as int?; } } @@ -142,9 +141,10 @@ class MixWithOthersMessage { class VideoPlayerApi { Future initialize() async { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); - final Map? replyMap = await channel.send(null) as Map?; + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); + final Map? replyMap = + await channel.send(null) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -152,7 +152,8 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = replyMap['error'] as Map; + final Map error = + replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -165,9 +166,10 @@ class VideoPlayerApi { Future create(CreateMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); - final Map? replyMap = await channel.send(encoded) as Map?; + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + final Map? replyMap = + await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -175,7 +177,8 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = replyMap['error'] as Map; + final Map error = + replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -188,9 +191,10 @@ class VideoPlayerApi { Future dispose(TextureMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); - final Map? replyMap = await channel.send(encoded) as Map?; + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + final Map? replyMap = + await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -198,7 +202,8 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = replyMap['error'] as Map; + final Map error = + replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -211,9 +216,10 @@ class VideoPlayerApi { Future setLooping(LoopingMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); - final Map? replyMap = await channel.send(encoded) as Map?; + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); + final Map? replyMap = + await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -221,7 +227,8 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = replyMap['error'] as Map; + final Map error = + replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -234,9 +241,10 @@ class VideoPlayerApi { Future setVolume(VolumeMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); - final Map? replyMap = await channel.send(encoded) as Map?; + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); + final Map? replyMap = + await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -244,7 +252,8 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = replyMap['error'] as Map; + final Map error = + replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -257,9 +266,11 @@ class VideoPlayerApi { Future setPlaybackSpeed(PlaybackSpeedMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', StandardMessageCodec()); - final Map? replyMap = await channel.send(encoded) as Map?; + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', + StandardMessageCodec()); + final Map? replyMap = + await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -267,7 +278,8 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = replyMap['error'] as Map; + final Map error = + replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -280,9 +292,10 @@ class VideoPlayerApi { Future play(TextureMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); - final Map? replyMap = await channel.send(encoded) as Map?; + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + final Map? replyMap = + await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -290,7 +303,8 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = replyMap['error'] as Map; + final Map error = + replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -303,9 +317,10 @@ class VideoPlayerApi { Future position(TextureMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); - final Map? replyMap = await channel.send(encoded) as Map?; + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + final Map? replyMap = + await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -313,7 +328,8 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = replyMap['error'] as Map; + final Map error = + replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -326,9 +342,10 @@ class VideoPlayerApi { Future seekTo(PositionMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); - final Map? replyMap = await channel.send(encoded) as Map?; + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + final Map? replyMap = + await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -336,7 +353,8 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = replyMap['error'] as Map; + final Map error = + replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -349,9 +367,10 @@ class VideoPlayerApi { Future pause(TextureMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); - final Map? replyMap = await channel.send(encoded) as Map?; + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + final Map? replyMap = + await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -359,7 +378,8 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = replyMap['error'] as Map; + final Map error = + replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, @@ -372,9 +392,11 @@ class VideoPlayerApi { Future setMixWithOthers(MixWithOthersMessage arg) async { final Object encoded = arg.encode(); - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', StandardMessageCodec()); - final Map? replyMap = await channel.send(encoded) as Map?; + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', + StandardMessageCodec()); + final Map? replyMap = + await channel.send(encoded) as Map?; if (replyMap == null) { throw PlatformException( code: 'channel-error', @@ -382,7 +404,8 @@ class VideoPlayerApi { details: null, ); } else if (replyMap['error'] != null) { - final Map error = replyMap['error'] as Map; + final Map error = + replyMap['error'] as Map; throw PlatformException( code: error['code'] as String, message: error['message'] as String?, diff --git a/packages/video_player/video_player_platform_interface/lib/test.dart b/packages/video_player/video_player_platform_interface/lib/test.dart index c42092b97b3a..457a838e8d24 100644 --- a/packages/video_player/video_player_platform_interface/lib/test.dart +++ b/packages/video_player/video_player_platform_interface/lib/test.dart @@ -23,8 +23,9 @@ abstract class TestHostVideoPlayerApi { void setMixWithOthers(MixWithOthersMessage arg); static void setup(TestHostVideoPlayerApi? api) { { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.initialize', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.initialize', + StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { @@ -36,13 +37,14 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.create', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.create was null. Expected CreateMessage.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.create was null. Expected CreateMessage.'); final CreateMessage input = CreateMessage.decode(message!); final TextureMessage output = api.create(input); return {'result': output.encode()}; @@ -50,13 +52,14 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.dispose', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.dispose was null. Expected TextureMessage.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.dispose was null. Expected TextureMessage.'); final TextureMessage input = TextureMessage.decode(message!); api.dispose(input); return {}; @@ -64,13 +67,15 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setLooping', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setLooping', + StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.setLooping was null. Expected LoopingMessage.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.setLooping was null. Expected LoopingMessage.'); final LoopingMessage input = LoopingMessage.decode(message!); api.setLooping(input); return {}; @@ -78,13 +83,15 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setVolume', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setVolume', + StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.setVolume was null. Expected VolumeMessage.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.setVolume was null. Expected VolumeMessage.'); final VolumeMessage input = VolumeMessage.decode(message!); api.setVolume(input); return {}; @@ -92,27 +99,31 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed', + StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed was null. Expected PlaybackSpeedMessage.'); - final PlaybackSpeedMessage input = PlaybackSpeedMessage.decode(message!); + assert(message != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.setPlaybackSpeed was null. Expected PlaybackSpeedMessage.'); + final PlaybackSpeedMessage input = + PlaybackSpeedMessage.decode(message!); api.setPlaybackSpeed(input); return {}; }); } } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.play', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.play was null. Expected TextureMessage.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.play was null. Expected TextureMessage.'); final TextureMessage input = TextureMessage.decode(message!); api.play(input); return {}; @@ -120,13 +131,14 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.position', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.position was null. Expected TextureMessage.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.position was null. Expected TextureMessage.'); final TextureMessage input = TextureMessage.decode(message!); final PositionMessage output = api.position(input); return {'result': output.encode()}; @@ -134,13 +146,14 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.seekTo', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.seekTo was null. Expected PositionMessage.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.seekTo was null. Expected PositionMessage.'); final PositionMessage input = PositionMessage.decode(message!); api.seekTo(input); return {}; @@ -148,13 +161,14 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.pause', StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.pause was null. Expected TextureMessage.'); + assert(message != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.pause was null. Expected TextureMessage.'); final TextureMessage input = TextureMessage.decode(message!); api.pause(input); return {}; @@ -162,14 +176,17 @@ abstract class TestHostVideoPlayerApi { } } { - const BasicMessageChannel channel = - BasicMessageChannel('dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', StandardMessageCodec()); + const BasicMessageChannel channel = BasicMessageChannel( + 'dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers', + StandardMessageCodec()); if (api == null) { channel.setMockMessageHandler(null); } else { channel.setMockMessageHandler((Object? message) async { - assert(message != null, 'Argument for dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers was null. Expected MixWithOthersMessage.'); - final MixWithOthersMessage input = MixWithOthersMessage.decode(message!); + assert(message != null, + 'Argument for dev.flutter.pigeon.VideoPlayerApi.setMixWithOthers was null. Expected MixWithOthersMessage.'); + final MixWithOthersMessage input = + MixWithOthersMessage.decode(message!); api.setMixWithOthers(input); return {}; }); diff --git a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart index cbedcbd1bc24..fae4b746bf05 100644 --- a/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart +++ b/packages/video_player/video_player_platform_interface/test/method_channel_video_player_test.dart @@ -61,8 +61,7 @@ class _ApiLogger implements TestHostVideoPlayerApi { PositionMessage position(TextureMessage arg) { log.add('position'); textureMessage = arg; - return PositionMessage() - ..position = 234; + return PositionMessage()..position = 234; } @override