Line data Source code
1 : import 'dart:io';
2 : import 'package:flutter_chrome_cast/_discovery_manager/android_discovery_manager.dart';
3 : import 'package:flutter_chrome_cast/_discovery_manager/discovery_manager_platform_interface.dart';
4 : import 'package:flutter_chrome_cast/_discovery_manager/ios_discovery_manager.dart';
5 :
6 : /// Main entry point for Google Cast device discovery functionality.
7 : ///
8 : /// This class provides a platform-agnostic interface for discovering Google Cast
9 : /// devices on the network. It automatically selects the appropriate platform-specific
10 : /// implementation based on the current operating system.
11 : class GoogleCastDiscoveryManager {
12 : static GoogleCastDiscoveryManagerPlatformInterface? _instance;
13 :
14 : /// Gets the singleton instance of the discovery manager.
15 : ///
16 : /// Returns the appropriate platform-specific implementation
17 : /// (Android or iOS) based on the current platform.
18 1 : static GoogleCastDiscoveryManagerPlatformInterface get instance {
19 1 : return _instance ??= Platform.isAndroid
20 0 : ? GoogleCastDiscoveryManagerMethodChannelAndroid()
21 1 : : GoogleCastDiscoveryManagerMethodChannelIOS();
22 : }
23 :
24 : /// Private constructor to enforce singleton pattern.
25 0 : GoogleCastDiscoveryManager._();
26 : }
|