From 9806f2181aaae64259883b4db76479ae9256bea5 Mon Sep 17 00:00:00 2001 From: Ryanidk Date: Thu, 14 Mar 2024 18:32:04 -0400 Subject: [PATCH 1/2] fix: catch errors --- lib/screens/send_data.dart | 94 +++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/lib/screens/send_data.dart b/lib/screens/send_data.dart index 71065e4..05a65a9 100644 --- a/lib/screens/send_data.dart +++ b/lib/screens/send_data.dart @@ -94,64 +94,64 @@ class _SendDataState extends State { Future sendDataToGoogleSheets() async { String message = ''; - //try { - final ss = await _gsheets.spreadsheet(_spreadsheetId); - var sheet; - if (widget.isGame) { - sheet = ss.worksheetByTitle(_gameWorksheetName); - } else { - sheet = ss.worksheetByTitle(_pitWorksheetName); - } + try { + final ss = await _gsheets.spreadsheet(_spreadsheetId); + var sheet; + if (widget.isGame) { + sheet = ss.worksheetByTitle(_gameWorksheetName); + } else { + sheet = ss.worksheetByTitle(_pitWorksheetName); + } - if (sheet != null) { - // Check for locally stored games - final prefs = await SharedPreferences.getInstance(); - final savedGames = prefs.getStringList('savedGames') ?? []; + if (sheet != null) { + // Check for locally stored games + final prefs = await SharedPreferences.getInstance(); + final savedGames = prefs.getStringList('savedGames') ?? []; - if (savedGames.isEmpty && widget.data.isEmpty) { - message = - "Shep couldn\'t find any saved games to send! That means IT'S TIME TO GO SCOUTING SOME MORE!!1!11!"; - } else { - if (widget.isGame) { - // Send locally stored games - for (final savedGame in savedGames) { - Map gameData = jsonDecode(savedGame); - var curSheet = ss.worksheetByTitle(_pitWorksheetName); - try { - if (gameData["isGame"] == "y") { - curSheet = ss.worksheetByTitle(_gameWorksheetName); + if (savedGames.isEmpty && widget.data.isEmpty) { + message = + "Shep couldn\'t find any saved games to send! That means IT'S TIME TO GO SCOUTING SOME MORE!!1!11!"; + } else { + if (widget.isGame) { + // Send locally stored games + for (final savedGame in savedGames) { + Map gameData = jsonDecode(savedGame); + var curSheet = ss.worksheetByTitle(_pitWorksheetName); + try { + if (gameData["isGame"] == "y") { + curSheet = ss.worksheetByTitle(_gameWorksheetName); + } + } catch (e) { + message = "Invalid Save Data"; + } + try { + gameData.remove("isGame"); + } catch (e) {} + List values = gameData.values.toList(); + final curRes = await curSheet!.values.appendRow(values); + if (curRes) { + message = "Successfully sent saved data!"; } - } catch (e) { - message = "Invalid Save Data"; - } - try { - gameData.remove("isGame"); - } catch (e) {} - List values = gameData.values.toList(); - final curRes = await curSheet!.values.appendRow(values); - if (curRes) { - message = "Successfully sent saved data!"; } + // Clear the saved games after sending them + final a = await prefs.setStringList('savedGames', []); } - // Clear the saved games after sending them - final a = await prefs.setStringList('savedGames', []); - } - if (widget.data.values.isNotEmpty) { - // Send current game - final values = widget.data.values.toList(); - print(values); - final result = await sheet.values.appendRow(values); - if (result) { - message = 'Shep collected the data, thanks scout! o7'; + if (widget.data.values.isNotEmpty) { + // Send current game + final values = widget.data.values.toList(); + print(values); + final result = await sheet.values.appendRow(values); + if (result) { + message = 'Shep collected the data, thanks scout! o7'; + } } } } - } - /*} catch (e) { + } catch (e) { message = 'Could not send data to sheets!'; print(e); - }*/ + } ScaffoldMessenger.of(context) .showSnackBar(SnackBar(content: Text(message))); From 9f3c353fef8259acbd7614a0ae0968847d3ece8a Mon Sep 17 00:00:00 2001 From: jwt <55862563+jwt2706@users.noreply.github.com> Date: Fri, 15 Mar 2024 20:01:37 -0400 Subject: [PATCH 2/2] Docs: coming soon tm --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 42e9267..3add2a8 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,9 @@ # MergeData -We mergin' the data fr. - -A scouting app developed by FRC Team 2706 Merge Robotics. +Robot scouting app developed by FRC Team 2706 Merge Robotics. +
Now featuring... a working Google Sheets integration!!! ## Documentation -we will update this as we work on stuff +Coming soon TM ## License This project is under the Apache 2.0 license, please read the `LICENSE` file for more information.