Introduction
In this article, I am going to show you how you can build a quick demo application that queries a web service and displays the results. Mastering the skills of quick prototyping with Flutter and a REST API can help you evaluate app ideas quickly.
Developing simple proof of concepts is a required ability in todayโs world as a software developer. Flutter is a perfect tool for these kinds of tasks because it allows you to focus on code while keeping the UI simple. Letโs get started right away!
Code
This is the complete code of the demo app with query logic, user interface, and data conversion. Pretty cool to get so much done with that many lines of code ?.
I am using aย FutureBuilder
ย as it can handle different states nicely. We have three states to consider:
- The query is running
- The query has successfully completed
- The query completed with an error
Theย future
ย parameter is assigned with an asynchronous methodย _httpGet()
ย to fetch the results. It uses theย httpย package and the publicly availableย Bored API. In theย builder
ย parameter, we can create the actual UI that is displayed depending on the state. To distinguish between the states, we can use theย ConnectionState
ย enum and theย AsyncSnapshot
ย class.
I already published an article with more details of how to work with REST APIs.

User interface

The UI is rather simple as this is not the main focus of a quick demo most of the time. We have aย StatefulWidget
ย with aย Scaffold
ย containing aย Card
ย widget with the result of the API call and anย ActionChip
ย with anย onPressed
ย handler to call the service once more. The handler just calls theย setState
ย function which triggers a rebuild of the page.
When the page is rebuilt, theย FutureBuilder
ย runs again and provides a new result to be displayed in the center of the screen.
Conclusion
In this article you learned quick prototyping with Flutter and a REST API can be done. I provided a simple example of a Flutter app that queries a REST API and displays the result. For experienced developers, this task wonโt take longer than half an hour. In my opinion, Flutter is ideal for rapid prototyping.
You can find the source code onย GitHub.
Related articles

