Skip to content

Commit 75effb3

Browse files
authored
Make getters in Mouse & Touchpad model nullable (#236)
* Make getters nullable for general section * Make getters nullable for mouse section * Make getters nullable for touchpad section
1 parent da63f5a commit 75effb3

File tree

3 files changed

+21
-23
lines changed

3 files changed

+21
-23
lines changed

lib/view/pages/mouse_and_touchpad/general_section.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ class GeneralSection extends StatelessWidget {
1919
labels: const ['Left', 'Right'],
2020
actionDescription:
2121
'Sets the order of physical buttons on mice and touchpads',
22-
selectedValues: [!model.leftHanded, model.leftHanded],
22+
selectedValues: model.leftHanded != null
23+
? [!model.leftHanded!, model.leftHanded!]
24+
: null,
2325
onPressed: (index) => model.setLeftHanded(index == 1),
2426
),
2527
],

lib/view/pages/mouse_and_touchpad/mouse_and_touchpad_model.dart

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ class MouseAndTouchpadModel extends ChangeNotifier {
3333

3434
// Global section
3535

36-
bool get leftHanded =>
37-
_peripheralsMouseSettings?.boolValue(_leftHanded) ?? false;
36+
bool? get leftHanded => _peripheralsMouseSettings?.boolValue(_leftHanded);
3837

3938
void setLeftHanded(bool value) {
4039
_peripheralsMouseSettings?.setValue(_leftHanded, value);
@@ -43,16 +42,16 @@ class MouseAndTouchpadModel extends ChangeNotifier {
4342

4443
// Mouse section
4544

46-
double get mouseSpeed =>
47-
_peripheralsMouseSettings?.doubleValue(_mouseSpeedKey) ?? 0.0;
45+
double? get mouseSpeed =>
46+
_peripheralsMouseSettings?.doubleValue(_mouseSpeedKey);
4847

4948
void setMouseSpeed(double value) {
5049
_peripheralsMouseSettings?.setValue(_mouseSpeedKey, value);
5150
notifyListeners();
5251
}
5352

54-
bool get mouseNaturalScroll =>
55-
_peripheralsMouseSettings?.boolValue(_mouseNaturalScrollKey) ?? false;
53+
bool? get mouseNaturalScroll =>
54+
_peripheralsMouseSettings?.boolValue(_mouseNaturalScrollKey);
5655

5756
void setMouseNaturalScroll(bool value) {
5857
_peripheralsMouseSettings?.setValue(_mouseNaturalScrollKey, value);
@@ -61,51 +60,48 @@ class MouseAndTouchpadModel extends ChangeNotifier {
6160

6261
// Touchpad section
6362

64-
double get touchpadSpeed =>
65-
_peripheralsTouchpadSettings?.doubleValue(_touchpadSpeedKey) ?? 0.0;
63+
double? get touchpadSpeed =>
64+
_peripheralsTouchpadSettings?.doubleValue(_touchpadSpeedKey);
6665

6766
void setTouchpadSpeed(double value) {
6867
_peripheralsTouchpadSettings?.setValue(_touchpadSpeedKey, value);
6968
notifyListeners();
7069
}
7170

72-
bool get touchpadNaturalScroll =>
73-
_peripheralsTouchpadSettings?.boolValue(_touchpadNaturalScrollKey) ??
74-
true;
71+
bool? get touchpadNaturalScroll =>
72+
_peripheralsTouchpadSettings?.boolValue(_touchpadNaturalScrollKey);
7573

7674
void setTouchpadNaturalScroll(bool value) {
7775
_peripheralsTouchpadSettings?.setValue(_touchpadNaturalScrollKey, value);
7876
notifyListeners();
7977
}
8078

81-
bool get touchpadTapToClick =>
82-
_peripheralsTouchpadSettings?.boolValue(_touchpadTapToClickKey) ?? true;
79+
bool? get touchpadTapToClick =>
80+
_peripheralsTouchpadSettings?.boolValue(_touchpadTapToClickKey);
8381

8482
void setTouchpadTapToClick(bool value) {
8583
_peripheralsTouchpadSettings?.setValue(_touchpadTapToClickKey, value);
8684
notifyListeners();
8785
}
8886

89-
bool get touchpadDisableWhileTyping =>
90-
_peripheralsTouchpadSettings?.boolValue(_touchpadDisableWhileTyping) ??
91-
false;
87+
bool? get touchpadDisableWhileTyping =>
88+
_peripheralsTouchpadSettings?.boolValue(_touchpadDisableWhileTyping);
9289

9390
void setTouchpadDisableWhileTyping(bool value) {
9491
_peripheralsTouchpadSettings?.setValue(_touchpadDisableWhileTyping, value);
9592
notifyListeners();
9693
}
9794

98-
bool get twoFingerScrolling =>
99-
_peripheralsTouchpadSettings?.boolValue(_touchpadTwoFingerScrolling) ??
100-
true;
95+
bool? get twoFingerScrolling =>
96+
_peripheralsTouchpadSettings?.boolValue(_touchpadTwoFingerScrolling);
10197

10298
void setTwoFingerScrolling(bool value) {
10399
_peripheralsTouchpadSettings?.setValue(_touchpadTwoFingerScrolling, value);
104100
notifyListeners();
105101
}
106102

107-
bool get edgeScrolling =>
108-
_peripheralsTouchpadSettings?.boolValue(_touchpadEdgeScrolling) ?? false;
103+
bool? get edgeScrolling =>
104+
_peripheralsTouchpadSettings?.boolValue(_touchpadEdgeScrolling);
109105

110106
void setEdgeScrolling(bool value) {
111107
_peripheralsTouchpadSettings?.setValue(_touchpadEdgeScrolling, value);

lib/view/pages/mouse_and_touchpad/mouse_section.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class MouseSection extends StatelessWidget {
2626
trailingWidget: const Text('Natural Scrolling'),
2727
actionDescription: 'Scrolling moves the content, not the view',
2828
value: model.mouseNaturalScroll,
29-
onChanged: (value) => model.setMouseNaturalScroll(value),
29+
onChanged: model.setMouseNaturalScroll,
3030
),
3131
],
3232
);

0 commit comments

Comments
 (0)