To fetch the recent played songs with last played duration, you can use the just_audio package to play audio files and get the current playback position. Then, you can use the shared_preferences package to store the recently played songs and their playback positions. You can add a listener to the positionStream to track the current playback position and store it in shared preferences. When a new song is played, its last playback position is retrieved from shared preferences and the song is played from that position. Finally, the song is added to the recently played list and its ID is stored in shared preferences. You can use the recent_songs list from shared preferences to display the recently played songs in your app, along with their last playback position.