A Flutter package allows you to obtain your public IP address

Related tags

Templates ip_address
Overview

IP Address

Pub Version Github

This package allows you to obtain your public IP address and many other information about it

Features

You can get the public IP address of the user or many other information about a specific IP address, such as :

  • Name of the country
  • Time Zone
  • Latitude
  • Longitude
  • Name of the City
  • Name of the Region
  • Region Code
  • Postal Code
  • The organization or Internet service provider
  • Continent Code
  • Two-letter ISO 3166-1 alpha-2 country code
  • Three-letter ISO 3166-1 alpha-3 country code
  • The UTC time offset
  • The Asn

Getting started

Add this to your dependencies :

dependencies:
  ip_address: ^1.0.0

And import :

import 'package:ip_address/ip_address.dart';

Usage

To get your ip address, just use IpAddress.getIp():

import 'package:ip_address/ip_address.dart';

void main() async {
  var ip = await IpAddress.getIp();
  print(ip);
  // Sample Output : 208.67.222.222
}

Don't forget to await it because it's a Future function.

Others functionalities

  • To get all data about the user's IP address , use getAllData() :
Map allData = await IpAddress.getAllData();

For a specific ip , use getAllDataFor('specific_ip') method instead .

  • To get only the user's IP address, use : IpAddress.getIp():
String ip = await IpAddress.getIp();
// Sample Output : "208.67.222.222"
  • To get the Ipv4 (Ip version 4) address value of the user's IP , use : IpAddress.getIpv4():
String ipv4 = await IpAddress.getIpv4();
// Sample Output : "208.67.222.222"
  • To get the Ipv6 (Ip version 6) address value of the user's IP , use : IpAddress.getIpv6():
String ipv6 = await IpAddress.getIpv6();
// Sample Output : "2a05:dfc7:5::53"
  • To get the Continent Code of the user's IP , use : IpAddress.getContinentCode():
String continentCode = await IpAddress.getContinentCode();
// Sample Output : "NA"

For a specific ip , use getContinentCodeFor('specific_ip') method instead .

  • To get the Country of the user's IP , use : IpAddress.getCountry():
String country = await IpAddress.getCountry();
// Sample Output : "United States"

For a specific ip , use getCountryFor('specific_ip') method instead .

  • To get the Two-letter ISO 3166-1 alpha-2 country code of the user's IP , use : IpAddress.getCountryCode():
String countryCode = await IpAddress.getCountryCode();
// Sample Output : "US"

For a specific ip , use getCountryCodeFor('specific_ip') method instead .

  • To get the Three-letter ISO 3166-1 alpha-3 country code of the user's IP , use : IpAddress.getCountryCode3():
String countryCode3 = await IpAddress.getCountryCode3();
// Sample Output : "USA"

For a specific ip , use getCountryCode3For('specific_ip') method instead .

  • To get the Latitude of the user's IP , use : IpAddress.getLatitude():
double latitude = await IpAddress.getLatitude();
// Sample Output : 37.7697

For a specific ip , use getLatitudeFor('specific_ip') method instead .

  • To get the Longitude of the user's IP , use : IpAddress.getLongitude():
double longitude = await IpAddress.getLongitude();
// Sample Output : -122.3933

For a specific ip , use getLongitudeFor('specific_ip') method instead .

  • To get the TimeZone of the user's IP , use : IpAddress.getTimeZone():
String timeZone = await IpAddress.getTimeZone();
// Sample Output : "America\/Los_Angeles"

For a specific ip , use getTimeZoneFor('specific_ip') method instead .

  • To get the UTC time offset of the user's IP , use : IpAddress.getOffset():
int offset = await IpAddress.getOffset();
// Sample Output : -7

For a specific ip , use getOffsetFor('specific_ip') method instead .

  • To get the organization or Internet service provider (ASN + ISP name) of the user's IP , use : IpAddress.getOrganization():
int organization = await IpAddress.getOrganization();
// Sample Output : "AS36692 OpenDNS, LLC"

For a specific ip , use getOrganizationFor('specific_ip') method instead .

  • To get the Name of the Region of the user's IP , use : IpAddress.getRegion():
String region = await IpAddress.getRegion();
// Sample Output : "New York"

For a specific ip , use getRegionFor('specific_ip') method instead .

  • To get the Region Code of the user's IP , use : IpAddress.getRegionCode():
String regionCode = await IpAddress.getRegionCode();
// Sample Output : "NY"

For a specific ip , use getRegionCodeFor('specific_ip') method instead .

  • To get the Name of the city of the user's IP , use : IpAddress.getCity():
String city = await IpAddress.getcity();
// Sample Output : "Brooklyn"

For a specific ip , use getCityFor('specific_ip') method instead .

  • To get the Postal code/Zip code of the user's IP , use : IpAddress.getPostalCode():
String postalCode = await IpAddress.getPostalCode();
// Sample Output : "11213"

For a specific ip , use getPostalCodeFor('specific_ip') method instead .

Additional information

Some countries do not have region and other information. For example, for some IP addresses outside the United States and Canada, information such as region, regionCode, city and postalCode may not be found.

You might also like...

Git+ is your ultimate GitLab mobile app that lets you interact with your projects like as if you were using desktop.

Git+ is your ultimate GitLab mobile app that lets you interact with your projects like as if you were using desktop.

Git+ for GitLab Git+ is your ultimate GitLab mobile app that lets you interact with your projects like as if you were using desktop. Git+ lets you see

Jan 7, 2023

This package allows you to draw dotted lines with Flutter.

This package allows you to draw dotted lines with Flutter.

About This package allows you to draw dotted lines with Flutter. Usage Parameter Default Description direction Axis.horizontal The direction of the en

Nov 16, 2022

A flutter deskstop package that allows you to drag the native file into app support.

A flutter deskstop package that allows you to drag the native file into app support.

FileDragAndDrop A flutter deskstop package that allows you to drag the native file into app support. Platform Support Now only support on macOS, if an

Oct 24, 2022

A Flutter package which allows you to work with MethodChannels in Isolate.

A Flutter package which allows you to work with MethodChannels in Isolate. Also it provides simplified multiplatform Isolate API.

Jan 4, 2023

This package allows you to scroll/select the value directly from the dropdown with less effort and time.

Direct Select This package allows you to scroll/select the value directly from the dropdown with less effort and time. Inspired by Virgil Pana shot Sa

Nov 25, 2022

A mobile application that allows you to search and fetch recipes using Flutter, TheMealDB and Domain Driven Design

recipe_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

Dec 4, 2021

A Flutter plugin that allows you to add an inline WebView.

native_webview A Flutter plugin that allows you to add an inline WebView. Motivation There is already a useful library for working with WebViews in Fl

Dec 14, 2022

A music player app that allows you to search for music by artist made using Flutter

A music player app that allows you to search for music by artist made using Flutter

Music Player A music player app that allows you to search for music by artist. Music source from iTunes affiliate API. Made using Flutter with simple

Feb 5, 2022

Christianlyrics - Flutter plugin that allows you build lyrics srt type of song

Christianlyrics - Flutter plugin that allows you build lyrics srt type of song

christian_lyrics Flutter plugin that allows you build lyrics srt type of song. G

Dec 5, 2022
Owner
Kab Agouda
Born to code 🖱️
Kab Agouda
Get google api credentials - A Dart CLI app to obtain credentials for accessing Google APIs

get_google_api_credentials A Dart CLI app to obtain credentials for accessing Go

null 1 Jan 28, 2022
Plugin for address picker

address_picker A flutter plugin for pick address. (Support VietNam Only) How to add lib to your project: dependencies: .... address_picker: gi

null 2 Nov 12, 2021
A mobile client for the public apis repository, 1400+ free apis to use able to be navigated through your phone :)

Public APIs mobile app Your assistant app that will help you discover and pick the next API for your next development project What it contains, you sa

Gwhyyy 4 Dec 25, 2022
BubbleShowcase is a small but power flutter package that allows you to highlight specific parts of your app to explain them to the user or to showcase your app new features.

BubbleShowcase BubbleShowcase is a small but powerful flutter package that allows you to highlight specific parts of your app (to explain them to the

Hugo Delaunay 38 Oct 26, 2022
This package adds CustomRefreshIndicator widget that allows you to create whatever indicator you want.

Custom Refresh Indicator A flutter package that allows you to easily create a custom refresh indicator widget. TLDR; ONLINE DEMO! QUICK START CustomRe

Kamil Klyta 315 Dec 16, 2022
Public interface definitions of Google APIs for Dart and gRPC

Public interface definitions of Google APIs for Dart and gRPC. Getting started I

Mahdi K. Fard 1 Feb 23, 2022
Mobile - Budipest - A community-based toilet finder app that seeks to alleviate the problem of public toilets in Hungary

Budipest | App Store | Google Play | Facebook What's the deal with the name? Bud

Budipest 2 Feb 7, 2022
A Flutter package allows you to Showcase/Highlight your widgets step by step.👌🔝🎉

ShowCaseView A Flutter package allows you to Showcase/Highlight your widgets step by step. Preview Installing Add dependency to pubspec.yaml Get the l

Simform Solutions 1.1k Jan 2, 2023
SoundVolumeView that displays general information and the current volume level for all active sound components in your system, and allows you to instantly mute and unmute them

SoundVolumeView that displays general information and the current volume level for all active sound components in your system, and allows you to instantly mute and unmute them

Domingo 4 Mar 4, 2022
Portarius is a free, open-source, cross-platform mobile application that allows you to manage your Portainer sessions.

Portarius [Latin: Porta/Door Arius/Keeper] Features User management See running/stopped containers (and also start/stop and restart them) See containe

Zbe 54 Jan 7, 2023