initialize method

Future<bool> initialize()

Implementation

Future<bool> initialize() async {
  globalKey = "${_config.current.customerPlaceCode}_";
  defaultStorage = "${globalKey}main";
  List<bool> allStorageLoaded = [];
  if (kIsWeb) {
    for (String tableName in Tables.all) {
      bool loaded = await _addStorageTable(databaseFactoryWeb, tableName);
      allStorageLoaded.add(loaded);
    }
  } else {
    _dbDirectory = await getApplicationDocumentsDirectory();
    for (String tableName in Tables.all) {
      String dbPath = await _createDatabaseDirectory(tableName);
      if (dbPath != "") {
        bool loaded = await _addStorageTable(databaseFactoryIo, tableName, dbPath);
        allStorageLoaded.add(loaded);
      } else {
        Logger.error("FOLDER NOT CREATED", "StorageService", "initialize");
        allStorageLoaded.add(false);
      }
    }
  }
  return (allStorageLoaded.isNotEmpty && allStorageLoaded.every((element) => true));
}