blob: 8f0bfc1dd1f0c6b9c2fd4b6f9e2fa6a3fa7ba06d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// SPDX-License-Identifier: Apache-2.0
import 'dart:io';
import 'package:meta/meta.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
// Media Volume
@immutable
class VehicleSignalMediaVolume {
const VehicleSignalMediaVolume({required this.volume});
final int volume;
VehicleSignalMediaVolume copyWith({int? volume}) {
return VehicleSignalMediaVolume(volume: volume ?? this.volume);
}
}
class VehicleSignalMediaVolumeNotifier
extends StateNotifier<VehicleSignalMediaVolume> {
VehicleSignalMediaVolumeNotifier() : super(_initialValue);
static final VehicleSignalMediaVolume _initialValue =
VehicleSignalMediaVolume(volume: 50);
void update({int? volume}) {
int? n = volume;
if (n != null) {
n = n.toUnsigned(8);
if (n > 100) n = 100;
}
state = state.copyWith(volume: n);
}
}
final vehicleSignalMediaVolumeProvider = StateNotifierProvider<
VehicleSignalMediaVolumeNotifier,
VehicleSignalMediaVolume>((ref) => VehicleSignalMediaVolumeNotifier());
// Inside Temperature
@immutable
class VehicleSignalInsideTemp {
const VehicleSignalInsideTemp({required this.temp});
final double temp;
VehicleSignalInsideTemp copyWith({double? temp}) {
return VehicleSignalInsideTemp(temp: temp ?? this.temp);
}
}
class VehicleSignalInsideTempNotifier
extends StateNotifier<VehicleSignalInsideTemp> {
VehicleSignalInsideTempNotifier() : super(_initialValue);
static final VehicleSignalInsideTemp _initialValue =
VehicleSignalInsideTemp(temp: 25);
void update({double? temp}) {
state = state.copyWith(temp: temp);
}
}
final vehicleSignalInsideTempProvider = StateNotifierProvider<
VehicleSignalInsideTempNotifier, VehicleSignalInsideTemp>(
(ref) => VehicleSignalInsideTempNotifier(),
);
// Outside Temperature
@immutable
class VehicleSignalOutsideTemp {
const VehicleSignalOutsideTemp({required this.temp});
final double temp;
VehicleSignalOutsideTemp copyWith({double? temp}) {
return VehicleSignalOutsideTemp(temp: temp ?? this.temp);
}
}
class VehicleSignalOutsideTempNotifier
extends StateNotifier<VehicleSignalOutsideTemp> {
VehicleSignalOutsideTempNotifier() : super(_initialValue);
static final VehicleSignalOutsideTemp _initialValue =
VehicleSignalOutsideTemp(temp: 32);
void update({double? temp}) {
state = state.copyWith(temp: temp);
}
}
final vehicleSignalOutsideTempProvider = StateNotifierProvider<
VehicleSignalOutsideTempNotifier, VehicleSignalOutsideTemp>(
(ref) => VehicleSignalOutsideTempNotifier(),
);
|