init method

Future<void> init({
  1. required String rootPath,
})

Implementation

Future<void> init({required String rootPath}) async {
  try {
    _root = rootPath;
    if (_root.isEmpty) {
      throw PathNotFoundException(
        _root,
        OSError(
          'TRecentDB: rootPath:`$_root` Not Found!.Usage: `await TRecentDB.getInstance.init(rootPath: \'test.json\')`',
        ),
      );
    }
    if (!File(_root).existsSync()) return;
    final source = await io.read(_root);
    _map = jsonDecode(source);
  } catch (e) {
    debugPrint('[TRecentDB:init]: ${e.toString()}');
  }
}