From 8a8ed536b008f6e708b576a47d18fe4907b45eae Mon Sep 17 00:00:00 2001 From: Codel1417 Date: Wed, 12 Jun 2024 14:22:32 -0400 Subject: [PATCH] minor changes --- lib/Frontend/pages/move_list.dart | 12 ++++++------ lib/Frontend/pages/ota_update.dart | 7 ++----- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/Frontend/pages/move_list.dart b/lib/Frontend/pages/move_list.dart index c02ff2be..1610a04f 100644 --- a/lib/Frontend/pages/move_list.dart +++ b/lib/Frontend/pages/move_list.dart @@ -173,7 +173,7 @@ class _EditMoveList extends ConsumerState with TickerProviderState floatingActionButton: moveList!.moves.length < 6 ? FloatingActionButton.extended( icon: const Icon(Icons.add), - onPressed: () { + onPressed: () async { setState( () { moveList!.moves.add(Move()); @@ -209,7 +209,7 @@ class _EditMoveList extends ConsumerState with TickerProviderState maxLines: 1, maxLength: 30, autocorrect: false, - onSubmitted: (nameValue) { + onSubmitted: (nameValue) async { setState( () { moveList!.name = nameValue; @@ -221,7 +221,7 @@ class _EditMoveList extends ConsumerState with TickerProviderState ), DeviceTypeWidget( selected: moveList!.deviceCategory, - onSelectionChanged: (List value) { + onSelectionChanged: (List value) async { setState(() => moveList!.deviceCategory = value.toList()); ref.watch(moveListsProvider.notifier).store(); }, @@ -235,7 +235,7 @@ class _EditMoveList extends ConsumerState with TickerProviderState max: 5, divisions: 4, label: "${moveList!.repeat.toInt()}", - onChanged: (double value) { + onChanged: (double value) async { setState(() { setState(() => moveList!.repeat = value); ref.watch(moveListsProvider.notifier).store(); @@ -253,7 +253,7 @@ class _EditMoveList extends ConsumerState with TickerProviderState key: Key('$index'), title: Text(moveList!.moves[index].toString()), leading: Icon(moveList!.moves[index].moveType.icon), - onTap: () { + onTap: () async { editModal(context, index); //context.push("/moveLists/editMoveList/editMove", extra: moveList!.moves[index]).then((value) => setState(() => moveList!.moves[index] = value!)); }, @@ -278,7 +278,7 @@ class _EditMoveList extends ConsumerState with TickerProviderState ); } - void editModal(BuildContext context, int index) { + Future editModal(BuildContext context, int index) async { Move move = moveList!.moves[index]; if (_tabController != null) { //There is probably a much better way to remove listeners diff --git a/lib/Frontend/pages/ota_update.dart b/lib/Frontend/pages/ota_update.dart index ad46ed1c..8698e46a 100644 --- a/lib/Frontend/pages/ota_update.dart +++ b/lib/Frontend/pages/ota_update.dart @@ -26,7 +26,7 @@ import '../translation_string_definitions.dart'; import '../utils.dart'; class OtaUpdate extends ConsumerStatefulWidget { - const OtaUpdate({super.key, required this.device}); + const OtaUpdate({required this.device, super.key}); final String device; @@ -79,9 +79,6 @@ class _OtaUpdateState extends ConsumerState { if (!wakelockEnabledBeforehand) { unawaited(WakelockPlus.disable()); } - if ([OtaState.download, OtaState.upload].contains(otaState)) { - otaState == OtaState.error; - } baseStatefulDevice?.deviceState.value = DeviceState.standby; baseStatefulDevice!.fwVersion.removeListener(verListener); baseStatefulDevice!.fwInfo.removeListener(fwInfoListener); @@ -426,7 +423,7 @@ class _OtaUpdateState extends ConsumerState { List beginOTA = List.from(const Utf8Encoder().convert("OTA ${firmwareFile!.length} $downloadedMD5")); await sendMessage(baseStatefulDevice!, beginOTA); - while (uploadProgress < 1 && otaState != OtaState.error) { + while (uploadProgress < 1 && otaState != OtaState.error && mounted) { baseStatefulDevice!.deviceState.value = DeviceState.busy; // hold the command queue if (baseStatefulDevice!.gearReturnedError.value) { transaction.status = const SpanStatus.unavailable();