2020-04-28 16:47:47 +00:00
|
|
|
import 'package:comunic/lists/abstract_list.dart';
|
|
|
|
import 'package:comunic/models/custom_emoji.dart';
|
|
|
|
|
|
|
|
/// Custom emojies list
|
|
|
|
///
|
|
|
|
/// @author Pierre HUBERT
|
|
|
|
|
|
|
|
class CustomEmojiesList extends AbstractList<CustomEmoji> {
|
2020-04-29 11:49:16 +00:00
|
|
|
/// Check if an emoji, identified by its shortcut, is present in this list
|
|
|
|
bool hasShortcut(String shortcut) =>
|
|
|
|
firstWhere((f) => f.shortcut == shortcut, orElse: () => null) != null;
|
|
|
|
|
2020-04-28 16:47:47 +00:00
|
|
|
/// Serialize this list
|
|
|
|
List<Map<String, dynamic>> toSerializableList() =>
|
|
|
|
map((f) => f.toMap()).toList();
|
|
|
|
|
|
|
|
/// Un-serialize this list
|
|
|
|
static CustomEmojiesList fromSerializedList(List<dynamic> list) =>
|
|
|
|
CustomEmojiesList()
|
|
|
|
..addAll(list.map((f) => CustomEmoji.fromMap(f)).toList());
|
|
|
|
}
|