ente/lib/models/search/recent_searches.dart

25 lines
614 B
Dart
Raw Normal View History

import "package:flutter/material.dart";
2023-11-01 09:46:38 +00:00
import "package:photos/core/constants.dart";
class RecentSearches with ChangeNotifier {
static RecentSearches? _instance;
RecentSearches._();
factory RecentSearches() => _instance ??= RecentSearches._();
final searches = <String>{};
void add(String query) {
searches.add(query);
2023-11-01 09:46:38 +00:00
while (searches.length > searchSectionLimit) {
searches.remove(searches.first);
}
2023-11-01 09:21:33 +00:00
//buffer for not surfacing a new recent search before going to the next
//screen
Future.delayed(const Duration(seconds: 1), () {
notifyListeners();
});
}
}