import 'dart:async'; import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:siopas/models/asset_status_model.dart'; import 'package:http/http.dart' as http; import 'package:internet_connection_checker/internet_connection_checker.dart'; import 'package:sqflite/sqflite.dart'; import '../../../migrations/databasehelper.dart'; class ControllerHome { final conn = SqfliteDatabaseHelper.instance; Future getPeminjamanCount() async { final dbClient = await conn.db; final count = Sqflite.firstIntValue(await dbClient! .query(SqfliteDatabaseHelper.peminjamanTable, columns: ['COUNT(*)'])); return count ?? 0; } Future getPengembalianCount() async { final dbClient = await conn.db; final count = Sqflite.firstIntValue( await dbClient!.query(SqfliteDatabaseHelper.pengembalianTable, columns: ['COUNT(*)']), ); return count ?? 0; } Future getTransferCount() async { final dbClient = await conn.db; final count = Sqflite.firstIntValue( await dbClient!.query(SqfliteDatabaseHelper.transferPetiTable, columns: ['COUNT(*)']), ); return count ?? 0; } static Future isInternet() async { var connectivityResult = await (Connectivity().checkConnectivity()); if (connectivityResult == ConnectivityResult.mobile) { if (await InternetConnectionChecker().hasConnection) { print("Mobile data detected & internet connection confirmed."); return true; } else { print('No internet :( Reason:'); return false; } } else if (connectivityResult == ConnectivityResult.wifi) { if (await InternetConnectionChecker().hasConnection) { print("wifi data detected & internet connection confirmed."); return true; } else { print('No internet :( Reason:'); return false; } } else { print( "Neither mobile data nor WIFI detected, no internet connection found."); return false; } } }