| 123456789101112131415161718192021222324252627282930313233343536373839 |
- /// Battery and connectivity snapshot shown on the home screen.
- class SystemStatus {
- const SystemStatus({
- this.batteryLevel = 0,
- this.charging = false,
- this.wifi = false,
- });
- final int batteryLevel;
- final bool charging;
- final bool wifi;
- factory SystemStatus.fromMap(Map<dynamic, dynamic> map) {
- return SystemStatus(
- batteryLevel: (map['batteryLevel'] as num?)?.toInt() ?? 0,
- charging: map['charging'] == true,
- wifi: map['wifi'] == true,
- );
- }
- }
- /// Current media-stream volume and its maximum.
- class VolumeInfo {
- const VolumeInfo({this.index = 0, this.max = 15});
- final int index;
- final int max;
- factory VolumeInfo.fromMap(Map<dynamic, dynamic> map) {
- return VolumeInfo(
- index: (map['index'] as num?)?.toInt() ?? 0,
- max: (map['max'] as num?)?.toInt() ?? 15,
- );
- }
- double get fraction => max <= 0 ? 0 : (index / max).clamp(0.0, 1.0);
- int get percent => (fraction * 100).round();
- }
|