@@ -53,7 +53,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
5353 onReady ();
5454 }
5555
56- setEvent (MediaEvent event) {
56+ void setEvent (MediaEvent event) {
5757 handleMediaEvent (event);
5858 mapMediaEventToMediaHandler (event);
5959
@@ -70,7 +70,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
7070 }
7171 }
7272
73- mapMediaEventToMediaHandler (MediaEvent event) {
73+ void mapMediaEventToMediaHandler (MediaEvent event) {
7474 if (! isTv && event.type != MediaEventType .progress) {
7575 log.fine ("Event state: ${event .state }, ${event .type }" );
7676 var playbackState = PlaybackState (
@@ -118,7 +118,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
118118 .indexWhere ((element) => element.videoId == currentVideoId);
119119 }
120120
121- onReady () async {
121+ Future < void > onReady () async {
122122 emit (state.copyWith (
123123 orientation: getOrientation (),
124124 forwardStep: settings.state.skipStep,
@@ -154,7 +154,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
154154 }
155155 }
156156
157- handleMediaEvent (MediaEvent event) {
157+ void handleMediaEvent (MediaEvent event) {
158158 switch (event.state) {
159159 case MediaState .completed:
160160 if (state.currentlyPlaying != null ) {
@@ -194,11 +194,11 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
194194 }
195195 }
196196
197- _setPip (bool pip) {
197+ void _setPip (bool pip) {
198198 emit (state.copyWith (isPip: pip));
199199 }
200200
201- _setMuted (bool muted) {
201+ void _setMuted (bool muted) {
202202 emit (state.copyWith (muted: muted));
203203 }
204204
@@ -222,20 +222,20 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
222222 }
223223 }
224224
225- setVideos (List <Video > videos) {
225+ void setVideos (List <Video > videos) {
226226 var newVideos = videos.where ((element) => ! element.filtered).toList ();
227227 emit (state.copyWith (videos: newVideos, offlineVideos: []));
228228 }
229229
230- selectTab (int index) {
230+ void selectTab (int index) {
231231 emit (state.copyWith (selectedFullScreenIndex: index));
232232 }
233233
234- setAudio (bool ? newValue) {
234+ void setAudio (bool ? newValue) {
235235 emit (state.copyWith (isAudio: newValue ?? false ));
236236 }
237237
238- hide () {
238+ void hide () {
239239 var mediaEvent = MediaEvent (
240240 state: MediaState .playing,
241241 type: MediaEventType .miniDisplayChanged,
@@ -274,7 +274,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
274274 }
275275*/
276276
277- saveProgress (int timeInSeconds) async {
277+ Future < void > saveProgress (int timeInSeconds) async {
278278 if (state.currentlyPlaying != null ) {
279279 int currentPosition = timeInSeconds;
280280 // saving progress
@@ -300,7 +300,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
300300 }
301301 }
302302
303- queueVideos (List <Video > videos) {
303+ void queueVideos (List <Video > videos) {
304304 var stateVideos = List <Video >.from (state.videos);
305305 if (videos.isNotEmpty) {
306306 //removing videos that are already in the queue
@@ -316,7 +316,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
316316 generatePlayQueue ();
317317 }
318318
319- showBigPlayer () {
319+ void showBigPlayer () {
320320 var mediaEvent = MediaEvent (
321321 state: MediaState .playing,
322322 type: MediaEventType .miniDisplayChanged,
@@ -327,7 +327,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
327327 onOrientationChange ();
328328 }
329329
330- showMiniPlayer () {
330+ void showMiniPlayer () {
331331 if (state.currentlyPlaying != null ||
332332 state.offlineCurrentlyPlaying != null ) {
333333 var mediaEvent = MediaEvent (
@@ -343,7 +343,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
343343 }
344344 }
345345
346- onProgress (Duration ? position) async {
346+ Future < void > onProgress (Duration ? position) async {
347347 var newPosition = position ?? Duration .zero;
348348 int currentPosition = newPosition.inSeconds;
349349 await saveProgress (currentPosition);
@@ -390,7 +390,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
390390 }
391391 }
392392
393- _playNextNow () async {
393+ Future < void > _playNextNow () async {
394394 if (settings.state.playerRepeatMode == PlayerRepeat .repeatOne) {
395395 seek (Duration .zero);
396396 play ();
@@ -426,12 +426,12 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
426426 }
427427 }
428428
429- playNext () {
429+ void playNext () {
430430 EasyThrottle .throttle (
431431 skipToVideoThrottleName, const Duration (seconds: 1 ), _playNextNow);
432432 }
433433
434- playPrevious () {
434+ void playPrevious () {
435435 EasyThrottle .throttle (skipToVideoThrottleName, const Duration (seconds: 1 ),
436436 () async {
437437 if (state.playedVideos.isNotEmpty) {
@@ -462,11 +462,11 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
462462 });
463463 }
464464
465- _setPlaying (bool playing) {
465+ void _setPlaying (bool playing) {
466466 emit (state.copyWith (isPlaying: playing));
467467 }
468468
469- _playVideos (List <IdedVideo > vids, {Duration ? startAt}) async {
469+ Future < void > _playVideos (List <IdedVideo > vids, {Duration ? startAt}) async {
470470 if (vids.isNotEmpty) {
471471 bool isOffline = vids[0 ] is DownloadedVideo ;
472472
@@ -507,7 +507,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
507507
508508 /// skip to queue video of index
509509 /// if we're not shuffling, we also rebuild the playnext and played previously queue
510- skipToVideo (int index) {
510+ void skipToVideo (int index) {
511511 var listToCheckAgainst =
512512 state.videos.isNotEmpty ? state.videos : state.offlineVideos;
513513 if (index < 0 || index >= listToCheckAgainst.length) {
@@ -533,7 +533,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
533533 }
534534
535535 /// Switches to a video without changing the queue
536- _switchToVideo (IdedVideo video, {Duration ? startAt}) async {
536+ Future < void > _switchToVideo (IdedVideo video, {Duration ? startAt}) async {
537537 try {
538538 // we move the existing video to the stack of played video
539539 await audioSession.setActive (true );
@@ -617,12 +617,13 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
617617 }
618618 }
619619
620- playOfflineVideos (List <DownloadedVideo > offlineVids) async {
620+ Future < void > playOfflineVideos (List <DownloadedVideo > offlineVids) async {
621621 log.fine ('Playing ${offlineVids .length } offline videos' );
622622 await _playVideos (offlineVids);
623623 }
624624
625- playVideo (List <Video > v, {bool ? audio, Duration ? startAt}) async {
625+ Future <void > playVideo (List <Video > v,
626+ {bool ? audio, Duration ? startAt}) async {
626627 List <Video > videos = v.where ((element) => ! element.filtered).toList ();
627628 // TODO: find how to do this with auto router
628629 log.fine ('Playing ${videos .length } videos' );
@@ -632,29 +633,29 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
632633 await _playVideos (videos, startAt: startAt);
633634 }
634635
635- switchToOfflineVideo (DownloadedVideo video) async {
636+ Future < void > switchToOfflineVideo (DownloadedVideo video) async {
636637 await _switchToVideo (video);
637638 }
638639
639- switchToVideo (Video video, {Duration ? startAt}) async {
640+ Future < void > switchToVideo (Video video, {Duration ? startAt}) async {
640641 await _switchToVideo (video, startAt: startAt);
641642 }
642643
643644 void togglePlaying () {
644645 state.isPlaying ? pause () : play ();
645646 }
646647
647- play () {
648+ void play () {
648649 emit (state.copyWith (
649650 mediaCommand: const MediaCommand (MediaCommandType .play)));
650651 }
651652
652- pause () {
653+ void pause () {
653654 emit (state.copyWith (
654655 mediaCommand: const MediaCommand (MediaCommandType .pause)));
655656 }
656657
657- removeVideoFromQueue (String videoId) {
658+ void removeVideoFromQueue (String videoId) {
658659 var videos = List <Video >.from (state.videos);
659660 var offlineVideos = List <DownloadedVideo >.from (state.offlineVideos);
660661 var listToUpdate = videos.isNotEmpty ? videos : offlineVideos;
@@ -716,12 +717,12 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
716717 }
717718
718719 bool isVideoInQueue (Video video) {
719- return state.videos. indexWhere (
720- ( element) => ( element.videoId ?? '' ) == video.videoId) >=
720+ return state.videos
721+ . indexWhere (( element) => element.videoId == video.videoId) >=
721722 0 ;
722723 }
723724
724- onQueueReorder (int oldItemIndex, int newItemIndex) {
725+ void onQueueReorder (int oldItemIndex, int newItemIndex) {
725726 log.fine ('Dragged video' );
726727 var videos = List <Video >.from (state.videos);
727728 var offlineVideos = List <DownloadedVideo >.from (state.offlineVideos);
@@ -763,7 +764,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
763764 }
764765 }
765766
766- setSponsorBlock () async {
767+ Future < void > setSponsorBlock () async {
767768 List <Pair <int >> newSegments = [];
768769 if (state.currentlyPlaying != null ) {
769770 List <SponsorSegmentType > types = SponsorSegmentType .values
@@ -787,7 +788,7 @@ class PlayerCubit extends Cubit<PlayerState> with WidgetsBindingObserver {
787788 emit (state.copyWith (sponsorSegments: newSegments));
788789 }
789790
790- seek (Duration duration) {
791+ void seek (Duration duration) {
791792 if (duration.inSeconds < 0 ) {
792793 duration = Duration .zero;
793794 }
0 commit comments