2024-05-08 05:03:49 -04:00
|
|
|
// does the initial setup of the storage
|
|
|
|
|
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
2024-05-12 05:38:30 -04:00
|
|
|
import 'package:flutter/material.dart';
|
2024-05-08 05:03:49 -04:00
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
|
import 'package:path/path.dart' as p;
|
|
|
|
|
import 'package:path_provider/path_provider.dart';
|
2024-08-23 04:21:46 -04:00
|
|
|
import 'package:vaani/settings/constants.dart';
|
2024-05-08 05:03:49 -04:00
|
|
|
|
|
|
|
|
import 'register_models.dart';
|
|
|
|
|
|
|
|
|
|
Future initStorage() async {
|
|
|
|
|
final dir = await getApplicationDocumentsDirectory();
|
|
|
|
|
|
2024-08-23 04:21:46 -04:00
|
|
|
// use vaani as the directory for hive
|
2024-05-08 05:03:49 -04:00
|
|
|
final storageDir = Directory(p.join(
|
|
|
|
|
dir.path,
|
2024-05-12 05:38:30 -04:00
|
|
|
AppMetadata.appNameLowerCase,
|
2024-05-08 05:03:49 -04:00
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
await storageDir.create(recursive: true);
|
|
|
|
|
|
|
|
|
|
Hive.defaultDirectory = storageDir.path;
|
2024-05-12 05:38:30 -04:00
|
|
|
debugPrint('Hive storage directory init: ${Hive.defaultDirectory}');
|
2024-05-08 05:03:49 -04:00
|
|
|
|
|
|
|
|
await registerModels();
|
|
|
|
|
}
|