Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
44 lines (38 sloc) 1.08 KB
import 'dart:io';
import 'package:dio/dio.dart';
main() async {
var dio = new Dio(new BaseOptions(
baseUrl: "",
connectTimeout: 5000,
receiveTimeout: 100000,
// 5s
headers: {
HttpHeaders.userAgentHeader: "dio",
"api": "1.0.0",
contentType: ContentType.json,
// Transform the response data to a String encoded with UTF8.
// The default value is [ResponseType.JSON].
responseType: ResponseType.plain,
Response<String> response;
response = await dio.get("/test");
Response<Map> responseMap = await dio.get(
// Transform response data to Json Map
options: new Options(responseType: ResponseType.json),
response = await
data: {
"id": 8,
"info": {"name": "wendux", "age": 25}
// Send data with "application/x-www-form-urlencoded" format
options: new Options(
contentType: ContentType.parse("application/x-www-form-urlencoded")),
You can’t perform that action at this time.