1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| var dio = Dio(BaseOptions( baseUrl: 'https://www.wanandroid.com/', connectTimeout: 5000, receiveTimeout: 100000, headers: { HttpHeaders.userAgentHeader: 'dio', 'api': '1.0.0', }, contentType: Headers.jsonContentType, responseType: ResponseType.plain, )); Response response; dio.interceptors.add(InterceptorsWrapper( onRequest: (options, handler) { return handler.next(options); }, onResponse: (response, handler) { return handler.next(response); }, onError: (DioError e, handler) { })); response = await dio.post( '/user/login', data: {'username': 'wanandroidUser1', 'password': '123456'}, // Send data with "application/x-www-form-urlencoded" format options: Options( contentType: Headers.formUrlEncodedContentType, ), ); print(response.data); }
|