0

I want to check if device is connected to WiFi or on Mobile Data, I am using connectivity, but it times out when there is no Active Internet connection on WiFi, I want enable some functions if there is no Active connections but is still connected to any WiFi

Hope it clears my doubt, Thanks

Yogesh Chawla
  • 595
  • 5
  • 20

1 Answers1

0

hope can help you

ref: https://stackoverflow.com/a/49648870/5588637

import 'dart:io';
...
try {
  final result = await InternetAddress.lookup('google.com');
  if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
    print('connected');
  }
} on SocketException catch (_) {
  print('not connected');
}
CH Wing
  • 1,062
  • 1
  • 12
  • 21
  • Actually, what I want is to get the status of device WiFi, if it is connected to certain network it should be able to detect although the WiFi may or may not have an active Internet connection – Yogesh Chawla Aug 24 '20 at 07:40