ActiveList.fromJson constructor

ActiveList.fromJson(
  1. dynamic json
)

Implementation

ActiveList.fromJson(dynamic json) {
  try {
    _pinned = json['pinned'];
    _clientId = json['clientId'];

    // Safe parsing for streamId to handle different device formats
    if (json['streamId'] != null) {
      if (json['streamId'] is int) {
        _streamId = json['streamId'];
      } else {
        String streamIdStr = json['streamId'].toString();
        _streamId = int.tryParse(streamIdStr) ?? 0;
      }
    } else {
      _streamId = 0;
    }

    _videomuted = json['videomuted'];
    _name = json['name'];
    _videoaspectratio = json['videoaspectratio'];
    _mediatype = json['mediatype'];
  } catch (e) {
    print('Error parsing ActiveList JSON: $e');
    // Set default values if parsing fails
    _pinned = false;
    _clientId = '';
    _streamId = 0;
    _videomuted = false;
    _name = '';
    _videoaspectratio = '16:9';
    _mediatype = 'audiovideo';
  }
}