Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternative library in Flutter like Reachability in iOS?

Tags:

flutter

Im new in Flutter Framework and unable to find any replacement library for internet availability like we have Reachability in iOS. any help will be appreciated. Thanks.

like image 971
MRizwan33 Avatar asked Dec 17 '25 23:12

MRizwan33


2 Answers

You can build reactive layouts using a StreamBuilder and the connectivity plugin:

StreamBuilder(
  stream: Connectivity().onConnectivityChanged,
  builder: (BuildContext context, AsyncSnapshot<ConnectivityResult> result) {
    if (result.data == ConnectivityResult.wifi)
      return Text('wifi');
    return Text('no wifi');
  }
)
like image 146
creativecreatorormaybenot Avatar answered Dec 20 '25 16:12

creativecreatorormaybenot


You can use connectivity plugin. This plugin works for iOS and Android.

Sample usage to check current status:

import 'package:connectivity/connectivity.dart';

    var connectivityResult = await (new Connectivity().checkConnectivity());
    if (connectivityResult == ConnectivityResult.mobile) {
      // I am connected to a mobile network.
    } else if (connectivityResult == ConnectivityResult.wifi) {
      // I am connected to a wifi network.
    }
like image 22
Shyju M Avatar answered Dec 20 '25 14:12

Shyju M