Commit 9181a728 authored by Q14's avatar Q14

封装网络库请求

parent b0695e84
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../netWork/DioUtil.dart';
// import '../netWork/DioUtil.dart';
// import 'package:dio/dio.dart';
// import 'dart:async';
class HomePage extends StatefulWidget { class HomePage extends StatefulWidget {
@override @override
...@@ -6,15 +10,38 @@ class HomePage extends StatefulWidget { ...@@ -6,15 +10,38 @@ class HomePage extends StatefulWidget {
} }
class _HomePageState extends State<HomePage> { class _HomePageState extends State<HomePage> {
void _incrementCounter() { void _incrementCounter() async {
setState(() { // print('Come------');
// This call to setState tells the Flutter framework that // // print('objectaaa');
// something has changed in this State, which causes it to rerun // DioUtil().get('/api/v1/suggestion',
// the build method below so that the display can reflect the // data: {
// updated values. If we changed _counter without calling // 'content': 'aaa',
// setState(), then the build method would not be called again, // // 'phone': '18601965003'
// and so nothing would appear to happen. // },
}); // errorCallback: (statusCode) {
// print('NNNNNNNN');
// print('Http error code : $statusCode');
// }
// ).then((data) {
// print('AAAAAAAA');
// print('Http response: $data');
// });
// try {
// Response response = await Dio().post("https://earth.iyanzhi.com/api/v1/suggestion", queryParameters: {'content': 'aaa','phone': '18601965003'
// });
// print(response);
// } catch (e) {
// print(e);
// }
// FormData formData = new FormData.from({
// "username": "username",
// "password": "password",
// });
DioUtil().requestR(Method.post, "/api/v1/suggestion",data: {"content": "add", "phone": "aaa"});
}
@override @override
......
This diff is collapsed.
This diff is collapsed.
...@@ -7,7 +7,7 @@ packages: ...@@ -7,7 +7,7 @@ packages:
name: async name: async
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.1.0" version: "2.2.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
...@@ -94,7 +94,7 @@ packages: ...@@ -94,7 +94,7 @@ packages:
name: quiver name: quiver
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "2.0.2" version: "2.0.3"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
...@@ -141,7 +141,7 @@ packages: ...@@ -141,7 +141,7 @@ packages:
name: test_api name: test_api
url: "https://pub.flutter-io.cn" url: "https://pub.flutter-io.cn"
source: hosted source: hosted
version: "0.2.4" version: "0.2.5"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment