Retrofit API call without Future Builder

Updated 29 April 2023

Save

Retrofit API call without Future Builder is used to call Rest API.

we can use it for sending dynamic headers, parameters, requests & responses in a more secure way.

In mobile app development connecting with the server(via API) to store or fetch the data is the most basic requirement.

So, in today’s blog, we check the Retrofit API call without Future Builder.

I hope we are all familiar with it, but we are not using Future Builder.

FutureBuilder is a widget by Flutter which lets you determine the current state of the Future.

Here we have discussed another approach of calling Rest API without Future Builder in Retrofit.

Check our Flutter app development services page.

Let’s Start The Steps For Retrofit API Calling In A Flutter Without Future Builder

Now, run the command “flutter pub get” to download the dependencies.

Right now, we will observe some errors in the file in part “api_client4.g.dart” and ApiClient1.

We need to run the command to generate an “api_client4.g.dar” file.

flutter pub run build_runner build

The above command will generate the api_client4.g.dart file. We should never modify the code in the api_client4.g.dart file by hand.

Therefore if we made any changes in ApiClient1. So we need to run the command to update the part file.

Please find below the complete code for main.dart class.

Finally, we can run the code and as a result, we can see the below output.

Conclusion

In this blog, we have discussed Retrofit API calling without using Future Builder.

I hope it will help you out in understanding and getting a brief idea about it.

Similarly, for more interesting blogs check out here – https://mobikul.com/blog/

Thank you for reading!!

References

https://pub.dev/packages/retrofit

https://medium.com/mindful-engineering/retrofit-the-easiest-way-to-call-rest-apis-is-flutter-fe55d1e7c5c2

author
. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home