LCOV - code coverage report
Current view: top level - common - volume.dart Coverage Total Hit
Test: lcov_cleaned.info Lines: 0.0 % 13 0
Test Date: 2025-06-20 10:50:47 Functions: - 0 0

            Line data    Source code
       1              : import 'dart:convert';
       2              : 
       3              : /// Represents the volume settings for a cast media session.
       4              : class CastMediaVolume {
       5              :   ///Optional current stream volume level as
       6              :   /// a value between 0.0 and 1.0 where 1.0
       7              :   ///  is the maximum volume.
       8              :   num? level;
       9              : 
      10              :   ///Optional whether the Cast device is muted,
      11              :   /// independent of the volume level.
      12              :   bool? muted;
      13              : 
      14              :   /// Creates a new [CastMediaVolume] instance.
      15              :   ///
      16              :   /// [level] - The volume level between 0.0 and 1.0.
      17              :   /// [muted] - Whether the volume is muted.
      18              :   ///
      19              :   /// Throws an assertion error if level is not between 0 and 1.
      20            0 :   CastMediaVolume(this.level, this.muted)
      21              :       : assert(
      22            0 :           level == null || (level >= 0 && level <= 1),
      23              :           'level must be between 0 and 1',
      24              :         );
      25              : 
      26              :   /// Converts the [CastMediaVolume] to a map.
      27              :   ///
      28              :   /// Returns a [Map] representation of this object.
      29            0 :   Map<String, dynamic> toMap() {
      30            0 :     return {
      31            0 :       'level': level,
      32            0 :       'muted': muted,
      33              :     };
      34              :   }
      35              : 
      36              :   /// Creates a [CastMediaVolume] from a map.
      37              :   ///
      38              :   /// [map] - The map to create the instance from.
      39            0 :   factory CastMediaVolume.fromMap(Map<String, dynamic> map) {
      40            0 :     return CastMediaVolume(
      41            0 :       map['level'],
      42            0 :       map['muted'],
      43              :     );
      44              :   }
      45              : 
      46              :   /// Converts the [CastMediaVolume] to a JSON string.
      47              :   ///
      48              :   /// Returns a JSON string representation of this object.
      49            0 :   String toJson() => json.encode(toMap());
      50              : 
      51              :   /// Creates a [CastMediaVolume] from a JSON string.
      52              :   ///
      53              :   /// [source] - The JSON string to create the instance from.
      54            0 :   factory CastMediaVolume.fromJson(String source) =>
      55            0 :       CastMediaVolume.fromMap(json.decode(source));
      56              : }
        

Generated by: LCOV version 2.3.1-1