Polishings
This commit is contained in:
@@ -6,7 +6,6 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:tasktracker/NotificationsManager.dart';
|
||||
|
||||
import 'main.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'dart:convert';
|
||||
@@ -14,11 +13,13 @@ import 'Data.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:device_info_plus/device_info_plus.dart';
|
||||
import 'package:sqflite_common/sqlite_api.dart';
|
||||
import 'package:sqflite_common_ffi/sqflite_ffi.dart' as SqlFF;
|
||||
import 'Tasks.dart';
|
||||
|
||||
late http.Response loginResponse;
|
||||
|
||||
late Database cacheDb;
|
||||
late var cacheDb;
|
||||
late String username;
|
||||
List<Category> categories = [];
|
||||
List<TaskType> taskTypes = [];
|
||||
@@ -72,8 +73,13 @@ Future<void> refreshUserData() async {
|
||||
NotificationManager.RescheduleNotifications();
|
||||
}
|
||||
Future<bool> cacheDbExist() async {
|
||||
Directory directory = await getApplicationDocumentsDirectory();
|
||||
return databaseFactory.databaseExists(directory.path + 'cache.db');
|
||||
if(Platform.isAndroid || Platform.isIOS){
|
||||
Directory directory = await getApplicationDocumentsDirectory();
|
||||
return databaseFactory.databaseExists(directory.path + 'cache.db');
|
||||
}else{
|
||||
Directory directory = await getApplicationDocumentsDirectory();
|
||||
return SqlFF.databaseFactoryFfi.databaseExists(directory.path + 'cache.db');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> updateCatsList() async {
|
||||
@@ -100,8 +106,11 @@ Future<void> updateActList() async {
|
||||
Future<void> initCacheDatabase() async {
|
||||
Directory directory = await getApplicationDocumentsDirectory();
|
||||
print('database at ' + directory.path + 'cache.db');
|
||||
cacheDb = await openDatabase(directory.path + 'cache.db', version: 1, onCreate: onCacheDatabaseCreate, onUpgrade: onCacheDatabaseUpgrade);
|
||||
|
||||
if(Platform.isAndroid || Platform.isIOS) {
|
||||
cacheDb = await openDatabase(directory.path + 'cache.db', version: 1, onCreate: onCacheDatabaseCreate, onUpgrade: onCacheDatabaseUpgrade);
|
||||
}else{
|
||||
cacheDb = await SqlFF.databaseFactoryFfi.openDatabase(directory.path + 'cache.db', options: OpenDatabaseOptions(version: 1,onCreate:onCacheDatabaseCreate ));
|
||||
}
|
||||
await UserOperations.executeQueries();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user