Reputation: 25
I am trying to access a variable called _country
from another file in dart, but an error occured: The getter '_country' isn't defined for the type 'CurrentCountry'.
Here's the code where the variable I want to access is(in another file):
class CurrentCountry {
static String _country = 'All';
}
And here's the code where I want to access the variable:
Future<Map<String, dynamic>> fetchWorldData() async {
Response activeResponse = await get(Uri.parse(
'https://disease.sh/v3/covid-19/countries/${CurrentCountry._country}'));
return json.decode(activeResponse.body);
}
If you can help me, I will be very grateful.
Upvotes: 0
Views: 261
Reputation: 4499
You should remove the underscore of the variable.
If an identifier starts with an underscore (_), it’s private to its library
Reference here: Dart language Important concepts
Upvotes: 1