DecibelData.fromMap constructor
Creates a DecibelData instance from a map.
The map should contain:
decibel: num (will be converted to double)timestamp: num (will be converted to double)
If values are missing, defaults to -120.0 dB and current timestamp.
Example:
final map = {
'decibel': -45.5,
'timestamp': 1234567890.0,
};
final data = DecibelData.fromMap(map);
Implementation
factory DecibelData.fromMap(Map<String, dynamic> map) {
return DecibelData(
decibel: (map['decibel'] as num?)?.toDouble() ?? -120.0,
timestamp: (map['timestamp'] as num?)?.toDouble() ??
DateTime.now().millisecondsSinceEpoch / 1000.0,
);
}