Line data Source code
1 : import 'package:flutter_chrome_cast/lib.dart';
2 :
3 : /// Extension for creating a list of [GoogleCastAndroidDevice] from a map.
4 : extension GoogleCastAndroidDevices on GoogleCastAndroidDevice {
5 : /// Creates a list of [GoogleCastAndroidDevice] from a list of maps.
6 1 : static List<GoogleCastAndroidDevice> fromMap(List maps) {
7 : final devices =
8 4 : maps.map((e) => GoogleCastAndroidDevice.fromMap(e)).toList();
9 : return devices;
10 : }
11 : }
12 :
13 : /// Android-specific device representation.
14 : class GoogleCastAndroidDevice extends GoogleCastDevice {
15 : /// Creates a new [GoogleCastAndroidDevice] instance.
16 1 : GoogleCastAndroidDevice({
17 : required super.deviceID,
18 : required super.friendlyName,
19 : required super.modelName,
20 : required super.statusText,
21 : required super.deviceVersion,
22 : required super.isOnLocalNetwork,
23 : required super.category,
24 : required super.uniqueID,
25 : });
26 :
27 : /// Creates a [GoogleCastAndroidDevice] from a map.
28 1 : factory GoogleCastAndroidDevice.fromMap(Map<String, dynamic> map) {
29 1 : return GoogleCastAndroidDevice(
30 1 : deviceID: map['id'],
31 1 : friendlyName: map['name'],
32 1 : modelName: map['model_name'],
33 1 : deviceVersion: map['device_version'],
34 : category: '',
35 1 : isOnLocalNetwork: map['is_on_local_network'],
36 : statusText: null,
37 1 : uniqueID: map['id'],
38 : );
39 : }
40 : }
|