
Music apps put a compact player above the bottom navigation. Tapping it opens a full playback screen; dragging that screen down returns it to the mini player. The tricky part is keeping playback consistent: both players must show the same track and position, and audio must not restart when the view changes.
Keep playback outside the transition
The mini player and the full player are separate widgets, so store playback state above both and pass it in:
class PlaybackModel extends ChangeNotifier {
Track track = tracks.first;
bool isPlaying = false;
void toggle() {
isPlaying = !isPlaying;
notifyListeners();
}
}
Expand the mini player
Scaffold(
body: const TrackList(),
bottomNavigationBar: SafeArea(
minimum: const EdgeInsets.fromLTRB(12, 0, 12, 12),
child: ExpandableAnimation(
controller: controller,
physics: ExpandableAnimationPhysics.smooth,
borderRadius: BorderRadius.circular(18),
collapsedColor: scheme.surfaceContainerHighest,
expandedColor: const Color(0xFF0E0E14),
semanticLabel: 'Open player',
expandedBuilder: (context) => FullPlayer(playback: playback),
child: MiniPlayer(playback: playback),
),
),
)
Both players listen to the same model with ListenableBuilder, so pressing pause in either
updates both, and the music keeps playing while the player morphs.
Open from anywhere
Selecting a track in the list can open the player through the controller:
onTap: () {
playback.select(index);
controller.expand();
},
Dismissal
- Drag the full player down: it shrinks, its corners round and the background fades.
- Release past the threshold or fling downward to collapse it into the mini player.
- A chevron button calls
ExpandableAnimation.of(context).collapse()for users who don't drag.
Try it
Open the music player demo. Related: tuning drag-to-dismiss.