I want to change some settings if i'm locally developing the app, such as:
settings.dart
bool debug = true;
String serverUrl;
if (debug) {
serverUrl = 'http://localhost';
} else {
serverUrl = 'https://myserver.com';
}
And then, use it with:
requests.dart
import 'settings.dart';
void fetchApi async () {
response = http.get(serverUrl);
// do some stuff
}
But actually, I can't use the if
function outside a function, the error says:
Expected an identifier.dart(missing_identifier)
Is there something that I can do to achieve this?
Thanks.