Firebase Remote Config

I have one String type variable API_URL and I want to get its value from Firebase Remote Config.

I want something like String API_URL = get_api_url();

I wrote following code to fetch it…

Future<String> get_api_url() async {
  final RemoteConfig remoteConfig = await RemoteConfig.instance;
  await remoteConfig.fetch(expiration: const Duration(hours: 0));
  await remoteConfig.activateFetched();
  return remoteConfig.getString('api_url');
}

But it is not working and has many issues. So please suggest a way. I would really appreciate any suggestion, help.