'Invalid argument(s): No host specified in URI flutter getconnect

I'm trying to use the Get Connect package to make an API call from my flutter application that totally depends on GetX .

Here is the code am using :

class OnBoardingProvider extends GetConnect {
  @override
  void onInit() {
    httpClient.baseUrl = 'https://www.my_domain_name.com/';
    httpClient.addRequestModifier((request) {
      request.headers['lang'] = Get.locale.languageCode;
      return request;
    });
    if (UserModelProvider().checkForLogin()) {
      httpClient.addAuthenticator((request) {
        String token = UserModelProvider().getToken();
        request.headers['Authorization'] = "Token $token";
        return request;
      });
    }
    super.onInit();
  }

  Future<List<dynamic>> getOnBoarding() async {
    final response = await get('static-pages/api/on_boarding/');
    return response.body;
  }

but it keeps showing me the error

Unhandled Exception: Invalid argument(s): No host specified in URI static-pages/api/on_boarding/

that means the line httpClient.baseUrl = ... didn't affect the code .. or maybe am calling it the wrong way !!

UPDATE

am calling the instance of OnBoardingProvider this way when I call the function :

    OnBoardingProvider().getOnBoarding().then((value) {
      print(value.body);
    });


Sources

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

Source: Stack Overflow

Solution Source