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

IPv4 geolocation from the free geolite2-city-json static dataset (MaxMind GeoLite2-City): country, region, city and coordinates for an IP address.

ip_geolocate #

IPv4 geolocation for Dart & Flutter, backed by the free geolite2-city-json dataset (derived from MaxMind's GeoLite2-City) served as static JSON from a CDN.

Install #

dart pub add ip_geolocate

Usage #

import 'package:ip_geolocate/ip_geolocate.dart';

Future<void> main() async {
  final loc = await geolocate('8.8.8.8');
  print(loc?.country);              // US
  print('${loc?.lat}, ${loc?.lon}'); // 37.751, -97.822
}

geolocate returns a GeoLocation?null means the dataset has no data for the address. The last few lookups are cached in memory, and concurrent lookups of the same address share a single request.

Any field of GeoLocation may be null:

field type meaning
country String? ISO 3166-1 alpha-2, e.g. US
region String? ISO 3166-2 subdivision, e.g. CA
city String? English city name
lat double? latitude
lon double? longitude
accuracyKm int? radius (km) around lat/lon the IP is likely within

Non-IPv4 input throws a FormatException.

Attribution #

Uses GeoLite2 data created by MaxMind, available from https://www.maxmind.com, under the GeoLite2 EULA. Package code is MIT-licensed. Not affiliated with or endorsed by MaxMind.

0
likes
160
points
1.17k
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

IPv4 geolocation from the free geolite2-city-json static dataset (MaxMind GeoLite2-City): country, region, city and coordinates for an IP address.

Repository (GitHub)
View/report issues

Topics

#geolocation #geoip #ip #maxmind

License

MIT (license)

Dependencies

http

More

Packages that depend on ip_geolocate