getRecentlyAdded function

Future<List<String>> getRecentlyAdded({
  1. int limit = 5,
  2. List<String>? customDefaultReactions,
})

Implementation

Future<List<String>> getRecentlyAdded(
    {int limit = 5, List<String>? customDefaultReactions}) async {
  List<Reaction> reactionsData =
      await ReactionProvider.instance.getRecentlyUsedReactions(limit: limit);
  List<String> reactions = reactionsData.map((e) => e.emoji).toSet().toList();
  if (reactions.length < limit) {
    List<String> defaultReactionsData = await getMostUsedReactions();
    reactions.addAll(defaultReactionsData);
  }
  if (customDefaultReactions != null) {
    reactions.insertAll(0, customDefaultReactions);
  }
  return reactions.toSet().toList();
}