You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.1 KiB
Dart
52 lines
1.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:connectivity/connectivity.dart';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:queuing_system/core/base/base_app_client.dart';
|
|
|
|
|
|
class ProjectViewModel with ChangeNotifier {
|
|
Locale _appLocale;
|
|
String currentLanguage = 'ar';
|
|
bool _isArabic = false;
|
|
bool isInternetConnection = true;
|
|
bool isLoading = false;
|
|
bool isError = false;
|
|
String error = '';
|
|
BaseAppClient baseAppClient = BaseAppClient();
|
|
|
|
Locale get appLocal => _appLocale;
|
|
|
|
bool get isArabic => _isArabic;
|
|
StreamSubscription subscription;
|
|
|
|
ProjectViewModel() {
|
|
|
|
subscription = Connectivity()
|
|
.onConnectivityChanged
|
|
.listen((ConnectivityResult result) {
|
|
switch (result) {
|
|
case ConnectivityResult.wifi:
|
|
isInternetConnection = true;
|
|
break;
|
|
case ConnectivityResult.mobile:
|
|
isInternetConnection = true;
|
|
break;
|
|
case ConnectivityResult.none:
|
|
isInternetConnection = false;
|
|
break;
|
|
}
|
|
notifyListeners();
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
void dispose() {
|
|
if (subscription != null) subscription.cancel();
|
|
super.dispose();
|
|
}
|
|
}
|