search method

List<EagleEntry> search({
  1. String? name,
  2. List<String>? tags,
  3. List<String>? folders,
})

Search entries by name, tags, and folders

Implementation

List<EagleEntry> search({
  String? name,
  List<String>? tags,
  List<String>? folders,
}) {
  final results = <EagleEntry>[];

  for (final entry in iterEntries()) {
    bool matches = true;

    // Check name filter
    if (name != null && name.isNotEmpty) {
      matches =
          matches &&
          entry._metadata.name.toLowerCase().contains(name.toLowerCase());
    }

    // Check tags filter
    if (tags != null && tags.isNotEmpty) {
      matches =
          matches && tags.any((tag) => entry._metadata.tags.contains(tag));
    }

    // Check folders filter
    if (folders != null && folders.isNotEmpty) {
      matches =
          matches &&
          folders.any((folder) => entry._metadata.folders.contains(folder));
    }

    if (matches) {
      results.add(entry);
    }
  }

  return results;
}