import 'dart:io'; class SearchService { static List searchNotes(String query, List notes) { if (query.isEmpty) return notes; final lowerQuery = query.toLowerCase(); return notes.where((note) { final fileName = note.uri.pathSegments.last.replaceAll('.md', '').toLowerCase(); final content = note.readAsStringSync().toLowerCase(); // Fuzzy search: Match if all words in the query are found in either the title or content return _matchesFuzzy(lowerQuery, fileName) || _matchesFuzzy(lowerQuery, content); }).toList(); } static bool _matchesFuzzy(String query, String text) { final words = query.split(RegExp(r'\s+')).where((word) => word.isNotEmpty); return words.every((word) => text.contains(word)); } }