WhatIsMyIp class
A class that provides functionality to retrieve IP addresses and their geolocation information.
This class uses two external APIs:
- Ipify API (https://api.ipify.org) to get the current IP address
- IP2Location API (https://api.ip2location.io) to get geolocation data for an IP address
Example usage:
final ipService = WhatIsMyIp();
// Get current IP address
final ipAddress = await ipService.getIpAddress();
// Get geolocation for current IP
final geolocation = await ipService.getIpGeolocation(
apiKey: 'your_api_key_here'
);
// Get geolocation for specific IP
final specificGeolocation = await ipService.getIpGeolocation(
apiKey: 'your_api_key_here',
ip: '8.8.8.8'
);
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getIpAddress(
) → Future< String> - Retrieves the current IP address using the Ipify API.
-
getIpGeolocation(
{required String apiKey, String? ip}) → Future< IpGeolocation> - Retrieves geolocation information for an IP address using the IP2Location API.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited