Get ip address (external not internal)

1,221 views
Skip to first unread message

Pascal Fournier

unread,
Jun 28, 2019, 9:51:55 AM6/28/19
to Flutter Development (flutter-dev)
Hello to all !

I have a small question... i use this package to get the user's ip address https://pub.dev/packages/get_ip

But it seems that i receive an internal ip address ?

When i do this :

String ipAddress = await GetIp.ipAddress;
print(ipAddress);

I receive 192.168.232.2... it's not my external ip address !!!
Note that i use an android emulator in Android Studio !

How can i get the internet IP Address ?

Thanks a lot !

Pascal

Pascal Fournier

unread,
Jun 28, 2019, 10:06:34 AM6/28/19
to Flutter Development (flutter-dev)
Just want to add more information.

I want to get user's IP Address to detect the country of the user (i use this database for my website : https://www.ip2location.com/ ) it's a database that we buy and it is updated monthly !

I suppose it's the same for mobile ? yes ?

Thanks a lot !
Pascal

Pascal Fournier

unread,
Jul 2, 2019, 4:58:45 PM7/2/19
to Flutter Development (flutter-dev)
Hello !

Is there any suggestions !

How can i get ip ?

Is there another way ?

Thanks a lot ! 

Marco Pariente-Cohen

unread,
Jul 3, 2019, 5:57:12 AM7/3/19
to Flutter Development (flutter-dev)
If you want the external ip address you'll need to "ask someone else" what it is.
The user's device will not know it's own ip address due to the router performing NAT (Network address translation).

Solution: I recommend parsing http://api.ipify.org/
The returned value is the external ip address that you are actually looking for.
-marco

Pascal Fournier

unread,
Jul 3, 2019, 8:20:18 AM7/3/19
to Flutter Development (flutter-dev)
Hello Marco !
Thanks for your reply ! I appreciate it ! 
I thought that to get the IP address of the user it was as simple as web development.
I found this package to get the location information. https://pub.dev/packages/location
I saw that we can get latitude and longitude....

Why getting the ip address is a bit harder than latitude and longitude?

What does the other apps use to geolocate users to provide specific content to each user depending where is the user?

Thanks a lot ! 

Pascal

Andy Greenshaw

unread,
Jul 3, 2019, 8:32:15 AM7/3/19
to Flutter Development (flutter-dev), Pascal Fournier
They use the latitude and longitude, then a reverse address “lookup” service from a provider company eg Google (the IP address maybe used by Android/iOS to help with determining the lat/long, but that is not your concern).
--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/5b93e08c-da11-4073-b602-c26f5180fc36%40googlegroups.com.

Pascal Fournier

unread,
Jul 3, 2019, 8:50:05 AM7/3/19
to Flutter Development (flutter-dev)
Hello Andy ! 
Ok i understand now ! 

thanks for you help ! I appreciate :)
Have a great day ! 

Pascal
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.

Andrea Salvatore

unread,
Jul 3, 2019, 9:15:33 AM7/3/19
to Pascal Fournier, Flutter Development (flutter-dev)
Hello Pascal,

the package you found asks for GPS access that is not something that people likes if now strictly necessary.

I'd suggest you to go with calls to free services that can return you pretty detailed informations. I personally use: http://ip-api.com/json

Usually those info are more than enough to locate the user without any access to the GPS.

Cheers,
Andrea

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.

Pascal Fournier

unread,
Jul 3, 2019, 9:22:49 AM7/3/19
to Flutter Development (flutter-dev)
Hello Andrea,

Thanks a lot for your reply ! I appreciate it !
Ok that's very good, i will check how to use it, That is exactly what i need !
I suppose it's an HTTP request and we receive the response.

I really appreciate !

Thanks a lot and have a great day :)

Pascal
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages