fetchBookmarks method

Future<List<Bookmark>?> fetchBookmarks({
  1. List<String>? profiles,
})

Implementation

Future<List<Bookmark>?> fetchBookmarks({List<String>? profiles}) async {
  assert(
    bookmarksFile != null,
    'Bookmarks are not supported for $name browser',
  );

  var bookmarkPaths = paths(profileFile: bookmarksFile!, profiles: profiles);

  for (var bookmarkPath in bookmarkPaths) {
    var file = File(bookmarkPath);

    var isExists = await file.exists();
    if (!isExists) continue;

    var size = await file.length();
    if (size == 0) continue;

    var dir = Directory.systemTemp.createTempSync();
    var f = File('${dir.path}/$bookmarksFile');
    await f.create();
    String tmpFile = f.path;

    await copyFile(File(bookmarkPath), tmpFile);

    return bookmarksParser(tmpFile);
  }
  return null;
}