Making your first http request with DIO

Import the DIO package

import 'package:dio/dio.dart';

Making your first http request with DIO

var dio = Dio();
Response response = await dio.get('https://google.com');
print(response.data);

The above example will make a request to http://google.com and print the result.

Additional Examples

Performing a GET request:

import 'package:dio/dio.dart';

Response response;
Dio dio = new Dio();

response = await dio.get("/test?id=12&name=wendu");
print(response.data.toString());

// Optionally the request above could also be done as
response = await dio.get("/test", queryParameters: {"id": 12, "name": "wendu"});
print(response.data.toString());

Performing a POST request:

Performing multiple concurrent requests:

Downloading a file:

Dio APIs

Creating an instance and set default configs.

You can create an instance of Dio with an optional BaseOptions object:

Last updated

Was this helpful?