'How to get My SharedPreference stored string in non Class file in dart?

I have constants.dart file and it contain all constant file including base url of my REST API. I need to change my REST API URL based on selected city which is already stored in shared preferences. I've attached my Code below.

Here is the Code



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source