Skip to content

Commit 4cd284c

Browse files
author
James Foster
committed
Update libraries and fix some new lint issues.
1 parent 1d11e03 commit 4cd284c

File tree

9 files changed

+330
-212
lines changed

9 files changed

+330
-212
lines changed

extras/device_client/lib/view/current_data_page.dart

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,18 @@ class CurrentData extends StatelessWidget {
8484
child: Text('ON'),
8585
),
8686
],
87-
onChanged: (String? newValue) {
88-
TcInterface.instance()
87+
onChanged: (String? newValue) async {
88+
await TcInterface.instance()
8989
.put(
9090
'${appData.currentData["IPAddress"]}',
9191
'data?$key=$newValue',
9292
)
9393
.then((value) {
9494
appData.currentData = json.decode(value);
9595
});
96-
Navigator.pop(context);
96+
if (context.mounted) {
97+
Navigator.pop(context);
98+
}
9799
},
98100
)
99101
else if (key == 'HeatOrChill')
@@ -109,31 +111,35 @@ class CurrentData extends StatelessWidget {
109111
child: Text('HEAT'),
110112
),
111113
],
112-
onChanged: (String? newValue) {
113-
TcInterface.instance()
114+
onChanged: (String? newValue) async {
115+
await TcInterface.instance()
114116
.put(
115117
'${appData.currentData["IPAddress"]}',
116118
'data?$key=$newValue',
117119
)
118120
.then((value) {
119121
appData.currentData = json.decode(value);
120122
});
121-
Navigator.pop(context);
123+
if (context.mounted) {
124+
Navigator.pop(context);
125+
}
122126
},
123127
)
124128
else
125129
TextFormField(
126130
initialValue: value,
127-
onFieldSubmitted: (val) {
128-
TcInterface.instance()
131+
onFieldSubmitted: (val) async {
132+
await TcInterface.instance()
129133
.put(
130134
'${appData.currentData["IPAddress"]}',
131135
'data?$key=$val',
132136
)
133137
.then((value) {
134138
appData.currentData = json.decode(value);
135139
});
136-
Navigator.pop(context);
140+
if (context.mounted) {
141+
Navigator.pop(context);
142+
}
137143
},
138144
),
139145
const SizedBox(height: 20),
@@ -209,8 +215,8 @@ class CurrentData extends StatelessWidget {
209215
final files = uploadInput.files;
210216
final file = files![0];
211217
final dynamic reader = html.FileReader();
212-
reader.onLoadEnd.listen((e) {
213-
sendArbitraryPathString(reader.result as String, ip);
218+
reader.onLoadEnd.listen((e) async {
219+
await sendArbitraryPathString(reader.result as String, ip);
214220
});
215221
reader.readAsDataUrl(file);
216222
});

0 commit comments

Comments
 (0)