dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.21k stars 1.57k forks source link

InternetAddress.reverse does not work on android #49608

Open guyluz11 opened 2 years ago

guyluz11 commented 2 years ago

Running the following code work in dart native but does not work inside a flutter app

final InternetAddress? internetAddressTemp =
    InternetAddress.tryParse('Ip_with_host');
InternetAddress internetAddress = await internetAddressTemp!.reverse();
print(internetAddress.host);

Getting the following exception

E/flutter ( 2090): [ERROR:flutter/runtime/dart_isolate.cc(1098)] Unhandled exception:
E/flutter ( 2090): SocketException: Failed reverse host lookup (OS Error: hostname nor servname provided, or not known, errno = 8), address = 192.168.1.66
E/flutter ( 2090): #0      _NativeSocket.reverseLookup.<anonymous closure> (dart:io-patch/socket_patch.dart:531:9)
guyluz11 commented 2 years ago

I can't reproduce on Flutter Linux

I guess it's an Android implementation or something with android permissions. My android app has the following permissions:

    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.INTERNET"/>

I can test it on Windows too if there is a need.

a-siva commented 2 years ago

Since this works on Dart CLI (Dart native) and not in a Flutter app you should probably file this issue against Flutter.