country_ip

Creator: coderz1093

Last updated:

Add to Cart

Description:

country ip

With country_ip you can find users' country (and nothing else) from their IP address.
This package is based on country.is. No API_KEY or AUTHORIZATION needed. Free to use API.
Features #

Find users' country using their current IP
Find country of a specified IP (Both IPv4 & IPv6 addresses supported)

Getting started #
To use this plugin, add country_ip as a dependency in your pubspec.yaml file.
dependencies:
country_ip: [latest-version]
copied to clipboard
Usage #
Import #
import 'package:country_ip/country_ip.dart';
copied to clipboard
Find country using current IP #
To find users' country from their current IP, call CountryIp.find()
Returns CountryResponse object which includes:

IP
Country
Country Code (ISO 3166 ALPHA-2)

On Error functions returns null object.
Example :
final countryIpResponse = await CountryIp.find();

print("countryIpResponse : $countryIpResponse");
// countryIpResponse : CountryResponse(country: United States, countryCode: US, ip: 9.9.9.9)
print("User's country code : ${countryIpResponse?.countryCode}");
// User's country code : US
print("User's country : ${countryIpResponse?.country}");
// User's country : United States
print("User's ip : ${countryIpResponse?.ip}");
// User's ip : 9.9.9.9
copied to clipboard
Find country of a specified IP #
To find country of a specified IP, call CountryIp.findFromIP(String ip)
Returns CountryResponse object which includes:

IP
Country
Country Code (ISO 3166 ALPHA-2)

On Error functions returns null object.
Examples :

Using IPv4

final countryIpResponse = await CountryIp.findFromIP('9.9.9.9');

print("countryIpResponse : $countryIpResponse");
// countryIpResponse : CountryResponse(country: United States, countryCode: US, ip: 9.9.9.9)
print("User's country code : ${countryIpResponse?.countryCode}");
// User's country code : US
print("User's country : ${countryIpResponse?.country}");
// User's country : United States
print("User's ip : ${countryIpResponse?.ip}");
// User's ip : 9.9.9.9
copied to clipboard

Using IPv6

final countryIpResponse = await CountryIp.findFromIP('::ffff:909:909');

print("countryIpResponse : $countryIpResponse");
// countryIpResponse : CountryResponse(country: United States, countryCode: US, ip: ::ffff:909:909)
print("User's country code : ${countryIpResponse?.countryCode}");
// User's country code : US
print("User's country : ${countryIpResponse?.country}");
// User's country : United States
print("User's ip : ${countryIpResponse?.ip}");
// User's ip : ::ffff:909:909
copied to clipboard
Issues #
Please file any issues, bugs or feature requests as an issue on our GitHub page.
Author #
This Country IP package is developed by NirmalCode.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.