Search code examples
flutterdartretrofit

Flutter - How to set dynamic base url in Retrofit API request?


Here is the example of my post API and I want to change the base URL for this particular API endpoint.

@POST("/post")
@FormUrlEncoded()
Future<String> postUrlEncodedFormData(@Field() String hello);

Solution

  • After some resource I got this solution and its work for me.

    @POST("http://www.your_base_url.com/post")
    @FormUrlEncoded()
    Future<String> postUrlEncodedFormData(@Field() String hello);