Skip to content
pubscout

public_ip_address

1.2.2, released 5 months ago by sumanrajpathak.com.np

Get public IP addresses and associated geolocation data like country, city, timezone, and ISP.

WASM-ready
$ flutter pub add public_ip_address
Source repository

What it does

The public_ip_address package allows you to retrieve the user's public IP address (both IPv4 and IPv6) as well as a wide range of geo-location and network details including country, region, city, latitude, longitude, timezone, and internet service provider (ASN). It also provides methods to query specific IP addresses instead of the current user's IP.

AI-written summary of version 1.2.2, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to display the user's public IP address in your app.
  • You need geolocation information derived from an IP address such as country, city, or time zone.

Skip it when

  • You require precise device GPS coordinates rather than IP-based geolocation.
  • You need offline IP lookup capabilities.

Strengths

  • Provides comprehensive IP metadata including location, timezone, and ISP details.
  • Supports fetching data for specific IP addresses as well as the current user's IP.
  • Cross-platform support covering Android, iOS, Web, Windows, macOS, and Linux.

Weaknesses

  • Relies on an external API endpoint which requires an active internet connection.
  • Region, city, and postal code data may be missing for certain non-US or non-Canadian IP addresses.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1

No native setup or special permissions are documented as required, other than standard internet connectivity via the http package.

import 'package:public_ip_address/public_ip_address.dart';

void main() async {
  IpAddress _ipAddress = IpAddress();
  var ip = await _ipAddress.getIp();
  print(ip);
}

Alternatives

Packages that do the same job and could replace public_ip_address.