mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-13 09:20:31 -07:00
feat: Improve library search screen (#477)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
This commit is contained in:
parent
571b682b80
commit
d22d340181
41 changed files with 2881 additions and 2026 deletions
|
|
@ -37,15 +37,30 @@ extension MapExtensions<T> on Map<T, bool> {
|
|||
bool get hasEnabled => values.any((element) => element == true);
|
||||
|
||||
//Replaces only keys that exist with the new values
|
||||
Map<T, bool> replaceMap(Map<T, bool> oldMap) {
|
||||
Map<T, bool> replaceMap(Map<T, bool> oldMap, {bool enabledOnly = false}) {
|
||||
if (oldMap.isEmpty) return this;
|
||||
|
||||
Map<T, bool> result = {};
|
||||
|
||||
forEach((key, value) {
|
||||
result[key] = oldMap[key] ?? false;
|
||||
if (enabledOnly) {
|
||||
if (oldMap[key] == true) {
|
||||
result[key] = true;
|
||||
} else {
|
||||
result[key] = value;
|
||||
}
|
||||
} else {
|
||||
result[key] = oldMap[key] ?? false;
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Map<T, bool> sortByKey(String Function(T value) keySelector) {
|
||||
final sortedEntries = entries.toList()..sort((a, b) => keySelector(a.key).compareTo(keySelector(b.key)));
|
||||
return Map<T, bool>.fromEntries(sortedEntries);
|
||||
}
|
||||
}
|
||||
|
||||
extension MapExtensionsGeneric<K, V> on Map<K, V> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue