fetchBookmarks method

Future<List<Bookmark>?> fetchBookmarks()

Implementation

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

  var bookmarkPaths = paths(profileFile: bookmarksFile!);

  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;
}