Skip to content

Commit

Permalink
Improved code (Playback icon button)
Browse files Browse the repository at this point in the history
  • Loading branch information
gokadzev committed Mar 21, 2024
1 parent 143e49a commit 1eb57af
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions lib/widgets/playback_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@ Widget buildPlaybackIconButton(
IconData icon;
VoidCallback? onPressed;

if (processingState == AudioProcessingState.loading ||
processingState == AudioProcessingState.buffering) {
icon = FluentIcons.spinner_ios_16_filled;
onPressed = null;
} else if (playing != true) {
icon = FluentIcons.play_circle_24_filled;
onPressed = audioHandler.play;
} else if (processingState != AudioProcessingState.completed) {
icon = FluentIcons.pause_circle_24_filled;
onPressed = audioHandler.pause;
} else {
icon = FluentIcons.replay_20_filled;
onPressed = () => audioHandler.seek(Duration.zero);
switch (processingState) {
case AudioProcessingState.buffering || AudioProcessingState.loading:
icon = FluentIcons.spinner_ios_16_filled;
onPressed = null;
break;
case AudioProcessingState.completed:
icon = FluentIcons.replay_20_filled;
onPressed = () => audioHandler.seek(Duration.zero);
break;
default:
icon = playing != true
? FluentIcons.play_circle_24_filled
: FluentIcons.pause_circle_24_filled;
onPressed = playing != true ? audioHandler.play : audioHandler.pause;
}

return InkWell(
Expand Down

0 comments on commit 1eb57af

Please sign in to comment.