dart 函数练习
import 'dart:convert'; import 'dart:html'; void main() { _getIPAddress() { final url = 'https://httpbin.org/ip'; HttpRequest.request(url).then((value) { print(json.decode(value.responseText)['origin']); }).catchError((error) => print(error)); } _getIPAddress(); }
114.92.6.153, 114.92.6.153
async
import 'dart:convert'; import 'dart:html'; void main() { _getIPAddress() async { final url = 'https://httpbin.org/ip'; var request = await HttpRequest.request(url); String ip = json.decode(request.responseText)['origin']; print(ip); } _getIPAddress(); }
转载 请注明原文地址并标明转载:http://www.cnblogs.com/laopo
商业用途请与我联系:lcfhn168@163.com