diff --git a/lib/main.dart b/lib/main.dart index 29edbf0..d1f260a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -83,9 +83,16 @@ class ServerPage extends StatelessWidget { ScaffoldMessenger.of(context).showSnackBar(SnackBar( content: Text("Login Success - Downloading remote Settings"))); + + int retryCount = 0; while (true) { try { - await Future.delayed(Duration(seconds: 5)); + if (retryCount > 0) + ScaffoldMessenger.of(context).showSnackBar(SnackBar( + content: Text( + "> Retrying to download settings in 10 seconds (Attempt $retryCount"))); + + await Future.delayed(Duration(seconds: 10)); S2CResponse settingsData = await settings.client! .send(C2SRequestSettingsPacket(), true); C2SRequestSettingsPacket settingsBack = @@ -93,7 +100,9 @@ class ServerPage extends StatelessWidget { settingsBack.decodeTag(settingsData.contents); settingsBack.handleClientPacket(); break; - } catch (E) {} + } catch (E) { + retryCount++; + } } Navigator.pushNamed(context, "/home");