import 'dart:async';
import 'package:connectivity_plus/connectivity_plus.dart';
class NetworkInfo {
final _connectivity = Connectivity();
Future get isConnected async {
var result = await _connectivity.checkConnectivity();
return result != ConnectivityResult.none;
}
Stream get onStatusChange =>
_connectivity.onConnectivityChanged.map((result) => result != ConnectivityResult.none);
}
void main() async {
final networkInfo = NetworkInfo();
bool connected = await networkInfo.isConnected;
print("Ulanish mavjudmi: $connected");
networkInfo.onStatusChange.listen((status) {
print("Ulanish holati o‘zgardi: $status");
});
}
import 'package:connectivity_plus/connectivity_plus.dart';
class NetworkInfo {
final _connectivity = Connectivity();
Future get isConnected async {
var result = await _connectivity.checkConnectivity();
return result != ConnectivityResult.none;
}
Stream get onStatusChange =>
_connectivity.onConnectivityChanged.map((result) => result != ConnectivityResult.none);
}
void main() async {
final networkInfo = NetworkInfo();
bool connected = await networkInfo.isConnected;
print("Ulanish mavjudmi: $connected");
networkInfo.onStatusChange.listen((status) {
print("Ulanish holati o‘zgardi: $status");
});
}