Skip to content

An example app that demonstrates how to handle some common network tasks in Flutter.

Notifications You must be signed in to change notification settings

hungnm138/devera-flutter-example-networking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo

Platform Flutter Made with Love

Buy me a coffee

Flutter Networking Examples

An example app that demonstrates how to handle some common network tasks in Flutter.

Getting Started

This example project is used in Devera Flutter course to demonstrate some practical sample of various networking tasks (incl. fetching data,...) in your Flutter app.

Introduction

In today’s world, smartphones have become the primary source of entertainment, banking, photo/videography and shopping. To do many of the things their users request, from ordering food to booking movie tickets, apps on your smartphone needs Internet access.

If you plan to develop apps that fetch data from the Internet, you’ll need to know how to make network requests and how to handle the responses properly.

Terminology

Before you start coding, take a moment to be sure that you understand some important terminology

What is a Network Request?

In simple terms, when you open an app like Whatsapp, Instagram or Twitter on your smartphone, the app tries to fetch the latest data from a remote location, usually called a Server. It then displays that information to the user. A server is a centralized place that stores most user data. The app that you’re using is called the Client.

Logo

So a network request is a request for data from a client to a server.

What is a RESTful API?

REST stands for REpresentational State Transfer. It’s an application program interface (API) that uses HTTP requests to get or send data between computers.

Communication between a client and a server mostly happens through RESTful APIs.

The most basic form of a REST API is a URL that the client uses to make a request to the server. Upon receiving a successful request, the server checks the endpoint of the URL, does some processing and sends the requested data or resource back to the client.

HTTP Methods

There are 4 main HTTP methods that you use in REST APIs. Here’s what each of them does:

  • GET: Requests a representation of the specified resource. Requests using GET only retrieve data – they should have no other effect on the data.
  • POST: Submits data to the specified resource. You use this method to send data to the server, such as customer information or file uploads.
  • DELETE: Deletes the specified resource.
  • PUT: Replaces all current representations of the target resource with the uploaded content. Now that you have some theory under your belt, you can move on to exploring the starter project.

Now that you have some theory under your belt, you can move on to exploring the project.

Pub Packages

Package Usage
HTTP A composable, multi-platform, Future-based API for HTTP requests.
Dio A powerful Http client for Dart, which supports Interceptors, FormData, Request Cancellation, File Downloading, Timeout etc.
Path Provider Flutter plugin for getting commonly used locations on host platform file systems, such as the temp and app data directories.
Provider State management and context based DI
JSON Serializable Automatically generate code for converting to and from JSON by annotating Dart classes.
JSON Annotation Classes and helper functions that support JSON code generation via the json_serializable package.
Build Runner A build system for Dart code generation and modular compilation.

Conclusion

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Also, visit the Devera Academy website or Facebook fanpage to find out more about the courses.


Buy Me A Coffee

About

An example app that demonstrates how to handle some common network tasks in Flutter.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published