mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 20:28:55 +03:30
commit
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:connectivity/connectivity.dart';
|
||||
|
||||
class ConnectivityProvider extends ChangeNotifier {
|
||||
String conStatus = '';
|
||||
|
||||
checkConnection() {
|
||||
Connectivity().onConnectivityChanged.listen((ConnectivityResult result) {
|
||||
conStatus = _getStatus(result);
|
||||
notifyListeners();
|
||||
});
|
||||
}
|
||||
|
||||
String _getStatus(ConnectivityResult result) {
|
||||
switch (result) {
|
||||
case ConnectivityResult.wifi:
|
||||
return 'wifi';
|
||||
break;
|
||||
case ConnectivityResult.mobile:
|
||||
return 'calcular';
|
||||
break;
|
||||
case ConnectivityResult.none:
|
||||
return 'offline';
|
||||
break;
|
||||
default:
|
||||
return 'offline';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user