I'm trying to set langauge from a Future call. I can see that future returns an object with data(value has languageCode property and it's data) but I cannot set that data to a String variable
class Api {
String language() {
String langaugeCode;
getLocale().then((value) => langaugeCode = value.languageCode);
return langaugeCode;
}
Future<List<Product>> getProduct() async {
var response = await http.get(BASE_URL + 'language?begins-with=' + language() , headers: headers());
}
}