当前位置 : 主页 > 网页制作 > html >

dart 函数练习

来源:互联网 收集:自由互联 发布时间:2021-06-12
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((err
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();
}
网友评论