import '../models/channel_details.dart'; import 'youtube_service.dart'; class ChannelPreviewMetadataService { ChannelPreviewMetadataService._(); static final ChannelPreviewMetadataService instance = ChannelPreviewMetadataService._(); final YoutubeService _youtube = YoutubeService(); final Map> _channelCache = >{}; Future getChannel( String? channelId, ) { final id = channelId?.trim() ?? ''; if (id.isEmpty) { return Future.value(null); } return _channelCache.putIfAbsent( id, () => _youtube.getChannelPreviewDetails(id), ); } void invalidate(String channelId) { _channelCache.remove(channelId); } }