import 'package:audioplayers/audioplayers.dart'; class AudioPlayerSingleton { static AudioPlayerSingleton? _instance; late AudioPlayer _audioPlayer; AudioPlayerSingleton._() { _audioPlayer = AudioPlayer(); } static AudioPlayerSingleton get instance { _instance ??= AudioPlayerSingleton._(); return _instance!; } Future playBeepSound() async { await _audioPlayer.play(AssetSource('sounds/beep.mp3')); } } // Usage: Future playBeepSound() async { await AudioPlayerSingleton.instance.playBeepSound(); }