load static method

Future<BTree> load(
  1. String path, {
  2. int order = 4,
  3. VfsAdapter? vfs,
})

Implementation

static Future<BTree> load(String path,
    {int order = 4, VfsAdapter? vfs}) async {
  final tree = BTree(order: order, path: path, vfs: vfs);
  if (vfs == null) return tree; // no VFS → empty tree

  if (!await vfs.exists(path)) return tree;
  try {
    final bytes   = await vfs.readAll(path);
    final content = utf8.decode(bytes);
    if (content.trim().isNotEmpty) {
      tree.root =
          BTreeNode.fromJson(jsonDecode(content) as Map<String, dynamic>);
    }
  } catch (e) {
    print('[BTree] Warning: could not load index from $path: $e');
  }
  return tree;
}