【问题标题】:How to get the IP address of a domain in Dart?如何在 Dart 中获取域的 IP 地址?
【发布时间】:2020-07-12 11:51:49
【问题描述】:

我想创建一个应用程序,它使用 flutter 获取用户输入的url 的 IP 地址(例如:www.google.com --> 216.58.197.78),我遇到了InternetAddress class 但我不知道如何使用它,我也不知道它是否是我正在寻找的东西。请帮我解决一下这个 。提前致谢。

【问题讨论】:

    标签: http flutter dart


    【解决方案1】:

    试试这个:

    InternetAddress.lookup("google.com").then((value) {
      value.forEach((element) async {
        print(element.address);
      });
    });
    

    【讨论】:

      【解决方案2】:

      使用ipfinder

      import 'package:ipfinder/ipfinder.dart';
      
      void main() async {
        Ipfinder ipfinder = Ipfinder("YOUR_TOKEN_GOES_HERE");
        IpResponse ip = await ipfinder.getAddressInfo("1.0.0.0");
        print(ip.toJson()); // print json data
      }
      

      【讨论】:

        猜你喜欢
        • 2011-04-04
        • 1970-01-01
        • 2012-05-11
        • 2011-01-28
        • 1970-01-01
        • 1970-01-01
        • 2012-09-04
        • 2016-02-26
        • 2011-12-02
        相关资源
        最近更新 更多