{"id":598,"date":"2023-02-18T19:45:21","date_gmt":"2023-02-18T11:45:21","guid":{"rendered":"http:\/\/gjweb.top\/?p=598"},"modified":"2023-02-18T19:45:22","modified_gmt":"2023-02-18T11:45:22","slug":"20-flutter%e8%af%b7%e6%b1%82%e6%8e%a5%e5%8f%a3","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=598","title":{"rendered":"20. Flutter\u8bf7\u6c42\u63a5\u53e3"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"map-\u548c-json-\u683c\u5f0f\u4e92\u8f6c\">MAP \u548c JSON \u683c\u5f0f\u4e92\u8f6c<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import \"dart:convert\";<br>json.encode(map) \/\/ map \u8f6c json<br>json.decode(json) \/\/  json \u8f6c map<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"dio-\u8bf7\u6c42\u63a5\u53e3-\u7b2c\u4e09\u65b9\">Dio \u8bf7\u6c42\u63a5\u53e3 \u7b2c\u4e09\u65b9<\/h2>\n\n\n\n<p>\u5f02\u6b65\u65b9\u5f0f\u53ef\u7528 .then \u548c async \/ await<\/p>\n\n\n\n<p>\u914d\u7f6e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dependencies:<br>    dio: ^4.0.6<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:dio\/dio.dart';<br>\/\/ \u83b7\u53d6\u6570\u636e<br>var response = await Dio().get('https:\/\/www.baidu.com',queryParmeters:{'name':\"zhangsan\"});<br>    print(response.data);<br>    print(response.data is Map);<br>}<br>\/\/ \u63d0\u4ea4\u6570\u636e<br>var response = await Dio().post('https:\/\/www.baidu.com',data:{'name':\"zhangsan\"});<br>    print(response.data);<br>    print(response.data is Map);<br>}<br>\/\/ \u66f4\u65b0\u6570\u636e<br>var response = await Dio().put('https:\/\/www.baidu.com',data:{'name':\"zhangsan\"});<br>    print(response.data);<br>    print(response.data is Map);<br>}<br>\/\/ \u5220\u9664\u6570\u636e<br>var response = await Dio().delete('https:\/\/www.baidu.com',queryParmeters:{'name':\"zhangsan\"});<br>    print(response.data);<br>    print(response.data is Map);<br>}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>MAP \u548c JSON \u683c\u5f0f\u4e92\u8f6c Dio \u8bf7\u6c42\u63a5\u53e3 \u7b2c\u4e09\u65b9 \u5f02\u6b65\u65b9\u5f0f\u53ef\u7528 .then \u548c async \/ awa [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-598","post","type-post","status-publish","format-standard","hentry","category-flutter"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/598","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=598"}],"version-history":[{"count":1,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/598\/revisions"}],"predecessor-version":[{"id":599,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/598\/revisions\/599"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=598"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}