Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REST API in flutter

I have a project in which I have a Python database and I have a Flutter ui.
Is there anyway I can use the REST API to connect them? My teammates who do the backend state that their database will use the REST API, so it would be useful if I can do that.

like image 686
Coder Avatar asked Aug 18 '18 18:08

Coder


Video Answer


1 Answers

Yes, you can easily use REST API's with Flutter.
Dart offers an http package for easy HTTP request and there are others available on Dart Pub.

With the http package, you can even integrate your REST API request into the build tree very easily using a FutureBuilder:

FutureBuilder(
  future: http.get('https://your-rest-api-domain.xyz/get-images?amount=5'),
  builder: (context, snapshot) {
    // you can easily work with your request results in here and return a widget
  },
)

As cricket_007 mentioned in a comment, Flutter also provides a cookbook entry on this topic.

like image 75
creativecreatorormaybenot Avatar answered Oct 14 '22 14:10

creativecreatorormaybenot