0

I am trying to access a variable called _countryfrom 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.

1 Answer 1

1

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

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.