Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

[Request]: network_info_plus: use ConnectivityManager for getWifiIP and getWifiGatewayIP from Android 7 (N), so ethernet works below Android 12

Abierto
#3,998 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@redge-munch ya está trabajando en esto.

Desde el 6/10/2026.

  • #3999 de @redge-munch — abierto

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
22/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
android, dart, flutter, kotlin

Línea de trabajo

Work is already in open PR #3999; do not start a duplicate. The Android path lives in the network_info_plus plugin: NetworkInfoPlusPlugin.setupChannels() currently constructs ConnectivityManager only from VERSION_CODES.S, and NetworkInfo.getWifiIPAddress() / getGatewayIPAddress() use the same S gate (WifiInfo/dhcpInfo below that). Confirm minSdk 19 still needs the Wi-Fi fallback below N. Done means ethernet IP/gateway work on API 24–30 without crashing getDhcpServerAddress on API 24–29.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

enhancement triage
Plugin

network_info_plus

Use case

If an Android device below version 12 is on ethernet, the plugin can't find the network:

  • getWifiIP() gives back null
  • getWifiSubmask() gives back an empty string
  • getWifiBroadcast() and getWifiIPv6() don't work either
  • getWifiGatewayIP() doesn't give the ethernet gateway

On Android 12 and up it works fine. The Android code uses ConnectivityManager there, and that works for any kind of connection. But it only turns on at Build.VERSION_CODES.S. Below that, the plugin uses WifiInfo and dhcpInfo instead. Those only know about Wi-Fi, so on ethernet they just give back 0.

The thing is, the ConnectivityManager calls are much older than Android 12. getActiveNetwork() is API 23, and the rest are API 21. The only newer one is getDhcpServerAddress(), which the gateway code uses. That one is API 30.

The S check came in with #1151. #420 asks for something similar, but this is just for Android.

Proposal

Turn on the ConnectivityManager code from Android 7 (Build.VERSION_CODES.N, API 24) instead of Android 12. That takes 3 small changes.

1. Get ConnectivityManager from N in NetworkInfoPlusPlugin.setupChannels()

Right now it's only set up on S and above, so it's null on older devices. If you only change the check in NetworkInfo.kt, nothing happens.

var connectivityManager: ConnectivityManager? = null
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
    connectivityManager = context.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
}

2. Change the check in NetworkInfo.getWifiIPAddress()

Only the version number changes. The rest stays the same.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
    val linkAddresses =
        connectivityManager?.getLinkProperties(connectivityManager.activeNetwork)?.linkAddresses
    // ...unchanged
}

3. Get the gateway from the default route in NetworkInfo.getGatewayIPAddress()

You can't just change the version number here. getDhcpServerAddress() needs API 30, so it would crash on API 24 to 29. The default route works from API 21. It's also a bit better on Android 12+, because it gives you the real gateway and not the DHCP server. Those aren't always the same thing.

return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
    val linkProperties =
        connectivityManager?.getLinkProperties(connectivityManager.activeNetwork)
    val defaultRoute = linkProperties?.routes?.firstOrNull { route -> route.isDefaultRoute }

    defaultRoute?.gateway?.hostAddress
} else {
    // ...existing dhcpInfo fallback, unchanged
}

Subnet mask, broadcast and IPv6 don't need any changes. They all use the IP from getWifiIPAddress(), so they start working once that does.

The plugin's minSdk is 19, so the old Wi-Fi code still runs on anything below N.

I tried this on ethernet on API 25, 28 and 30, and it works on all of them. Before the change, none of them showed anything. It might work on API 23 (M) too, but I haven't tried that.

Lenguaje dominante
Dart
Estrellas
1.9k
Forks
1.3k
Merge medio
4 d 2 h
PR fusionados (30 d)
15

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de fluttercommunity/plus_plugins

Todos los issues de fluttercommunity/plus_plugins

Issues similares

Más issues de Dart

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.