getHistorySearches method
Implementation
@override
Future<List<StoreRecentSearchEntity>> getHistorySearches() async {
try {
// deleteAllPreviousSearchHistory();
final SharedPreferences _sharedPreferences =
await SharedPreferences.getInstance();
List<StoreRecentSearchEntity> historyItem = [];
List<String> nameHistoryList =
_sharedPreferences.getStringList(SuperKeys.searchHistoryName) ?? [];
List<String> dateHistoryList =
_sharedPreferences.getStringList(SuperKeys.searchHistoryDate) ?? [];
for (int i = 0; i < nameHistoryList.length; i++) {
debugPrint('$i ${nameHistoryList[i]}');
historyItem.add(StoreRecentSearchEntity(
name: nameHistoryList[i], searchDate: dateHistoryList[i]));
}
return historyItem;
} catch (e) {
rethrow;
}
}