Line data Source code
1 : import 'package:flutter_chrome_cast/entities/cast_session.dart';
2 : import 'package:flutter_chrome_cast/enums/connection_state.dart';
3 : import 'package:flutter_chrome_cast/models/ios/ios_cast_device.dart';
4 :
5 : /// Represents a Google Cast session on iOS devices.
6 : ///
7 : /// This class extends [GoogleCastSession] and provides additional
8 : /// functionality specific to iOS, including a factory method for
9 : /// creating an instance from a map (typically from JSON).
10 : class IOSGoogleCastSessions extends GoogleCastSession {
11 : /// Creates an [IOSGoogleCastSessions] instance.
12 : ///
13 : /// All parameters are required and are passed to the superclass constructor.
14 0 : IOSGoogleCastSessions({
15 : required super.device,
16 : required super.sessionID,
17 : required super.connectionState,
18 : required super.currentDeviceMuted,
19 : required super.currentDeviceVolume,
20 : required super.deviceStatusText,
21 : });
22 :
23 : /// Creates an [IOSGoogleCastSessions] instance from a [Map] (e.g., JSON).
24 : ///
25 : /// Returns `null` if the input [json] is `null`.
26 : /// Throws if required fields are missing or of incorrect type.
27 0 : static IOSGoogleCastSessions? fromMap(Map<String, dynamic>? json) {
28 : if (json == null) return null;
29 0 : return IOSGoogleCastSessions(
30 0 : device: GoogleCastIosDevice.fromMap(
31 0 : Map<String, dynamic>.from(json['device'])),
32 0 : sessionID: json['sessionID'],
33 0 : connectionState: GoogleCastConnectState.values[json['connectionState']],
34 0 : currentDeviceMuted: json['currentDeviceMuted'],
35 0 : currentDeviceVolume: json['currentDeviceVolume'],
36 0 : deviceStatusText: json['deviceStatusText'] ?? '',
37 : );
38 : }
39 : }
|