From 9cb6e3e5b846647cf7e6ef9e33076b95e8e501a6 Mon Sep 17 00:00:00 2001 From: Ahmed Zamil Date: Sun, 18 Sep 2022 23:57:56 +0300 Subject: [PATCH] first --- lib/src/Data/AutoList.dart | 6 ++++++ lib/src/Data/KeyList.dart | 5 +++++ lib/src/Resource/Warehouse.dart | 1 + 3 files changed, 12 insertions(+) diff --git a/lib/src/Data/AutoList.dart b/lib/src/Data/AutoList.dart index e55e1c2..c06f8ed 100644 --- a/lib/src/Data/AutoList.dart +++ b/lib/src/Data/AutoList.dart @@ -73,6 +73,12 @@ class AutoList extends IDestructible with IterableMixin { emitArgs("add", [_state, value]); } + + T? first(bool Function(T element) selector) { + final res = _list.where(selector); + return res.isEmpty ? null : res.first; + } + /// /// Add an array of items to the list /// diff --git a/lib/src/Data/KeyList.dart b/lib/src/Data/KeyList.dart index 1f1f5b2..709d8e9 100644 --- a/lib/src/Data/KeyList.dart +++ b/lib/src/Data/KeyList.dart @@ -78,6 +78,11 @@ class KeyList extends IEventHandler with MapMixin { } } + T? first(bool Function(T element) selector) { + final res = _map.where(selector); + return res.isEmpty ? null : res.first; + } + _itemDestroyed(T sender) { removeValue(sender); } diff --git a/lib/src/Resource/Warehouse.dart b/lib/src/Resource/Warehouse.dart index 9939b28..8d87305 100644 --- a/lib/src/Resource/Warehouse.dart +++ b/lib/src/Resource/Warehouse.dart @@ -570,6 +570,7 @@ class Warehouse { /// .Net type. /// Resource template. static TypeTemplate? getTemplateByType(Type type) { + // loaded ? for (var tmps in _templates.values) for (var tmp in tmps.values) if (tmp.definedType == type) return tmp;