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();
}

 

posted @ 2019-08-12 12:00  每天进步一点点!  阅读(460)  评论(0编辑  收藏  举报