Line data Source code
1 : /// Represents a request, including progress, external status, request ID, and error.
2 : class GoogleCastRequest {
3 : /// Whether the request is in progress.
4 : final bool inProgress;
5 :
6 : /// Whether the request is external.
7 : final bool isExternal;
8 :
9 : /// The unique request ID.
10 : final int requestID;
11 :
12 : /// Error message, if any.
13 : final String? error;
14 :
15 : /// Creates a new [GoogleCastRequest] instance.
16 1 : GoogleCastRequest({
17 : required this.inProgress,
18 : required this.isExternal,
19 : required this.requestID,
20 : this.error,
21 : });
22 :
23 : /// Creates a [GoogleCastRequest] from a map, typically decoded from JSON.
24 : ///
25 : /// The [map] must contain the keys 'inProgress', 'isExternal', and 'requestID'.
26 : /// The 'error' key is optional.
27 1 : factory GoogleCastRequest.fromMap(Map<String, dynamic> map) {
28 1 : return GoogleCastRequest(
29 1 : inProgress: map['inProgress'] as bool? ?? false,
30 1 : isExternal: map['isExternal'] as bool? ?? false,
31 2 : requestID: map['requestID'] as int? ?? map['requestId'] as int? ?? 0,
32 1 : error: map['error'] as String?,
33 : );
34 : }
35 : }
|