ipwhois 1.1.0 copy "ipwhois: ^1.1.0" to clipboard
ipwhois: ^1.1.0 copied to clipboard

A Dart package for retrieving some information about IP that is connected to the internet. such as city & country name, continent code, latitude and longitude, IP v4 or v6.

img

ipwhois #

pub package

By using ipwhois package, you can get information about the IP of your Internet connection. such as IP address v4 and v6, city name, country name, region, latitude and longitude, continent code, timezone, Internet provider organization ....

  • After the answer comes and the country or city is specified, you can render different designs based on the type of country or city.
  • Changing the language of the application by identifying different IPs.

🌐 🛜 💻 📱

Install Package #

add the following line to your pubspec.yaml under dependencies:

dependencies:
  ipwhois: ^1.1.0

then run:

dart pub get

or

flutter pub get

Getting started #

Android #

add this permission to your <project root>/android/app/src/main/AndroidManifest.xml


<uses-permission android:name="android.permission.INTERNET"/>

import it

import 'package:ipwhois/ipwhois.dart';

Usage #

now in your dart code, you can use:

final IpInfo? resultV4 = await getMyIpInfo();
print(resultV4); // ip: 5.200.119.128, continentCode: AS, country: Iran, countryCode: IR, countryCode3: IRN, region: Tehran, regionCode: 23, city: Tehran, latitude: 35.7108, longitude: 51.4274, timezone: Asia/Tehran, offset: 12600, asn: 57218, organization: Rightel Communication Service Company PJS

if (resultV4 != null) {
  print(resultV4!.ip);  // ip: 5.200.119.128
  print(resultV4.city);  // Tehran
  print(resultV4.country);  // Iran
  print(resultV4.countryCode);  // IR
  print(resultV4.latitude);  // 35.7108
  print(resultV4.longitude);  // 51.4274
  print(resultV4.continentCode);  // AS
  print(resultV4.region);  // Tehran
  print(resultV4.regionCode);   // 23
  print(resultV4.organization);  // Rightel Communication Service Company PJS
}

final resultV6 = await getMyIpInfo(version: IpVersion.v6);
print(resultV6); // null

you can only request to get the IP

final String? myIpV4 = await getMyIp();
print(myIpV4);  // 77.73.69.217

final String? myIpV6 = await getMyIp(version: IpVersion.v6);
print(myIpV6);  // 2a00:1838:37:21e::d3bc

by Shervin Hassanzadeh #

contact me at

linkedin Email telegram github stackoverflow
5
likes
160
points
78
downloads

Publisher

unverified uploader

Weekly Downloads

A Dart package for retrieving some information about IP that is connected to the internet. such as city & country name, continent code, latitude and longitude, IP v4 or v6.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

http

More

Packages that depend on ipwhois