Is there a function in Dart which acts as an equivalent to the Goto function, wherein I could transfer the programs control to a specified label.
For example:
var prefs = await SharedPreferences.getInstance();
if (prefs.getString("TimetableCache") == null || refreshing) {
var response = await http.get(
Uri.encodeFull("A website",);
data = JsonDecoder().convert(response.body);
try {
if (response != null) {
prefs.setString("TimetableCache", response.body);
}
} catch (Exception) {
debugPrint(Exception);
}
} else {
data = prefs.getString("TimetableCache");
}
if (data != null) {
try {
//Cool stuff happens here
} catch (Exception) {
prefs.setString("TimetableCache", null);
}
}
I have an http request and before I want to move on with my 'cool stuff' I have a try catch which sees if anything is in the TimetableCache
location of the SharedPreferences
of the machine. When it catches the exception I would ideal have a goto method to send it back to the top line again to retry getting the data.
In c# you can use goto refresh;
, for example, and the code will then start executing wherever the identifier refresh:
is.
Is there a dart version of this?