Favourites

This commit is contained in:
Mguy13 2022-12-25 01:55:53 +01:00
parent 6a84a9bef0
commit 1747ab0245
23 changed files with 469 additions and 67 deletions

View file

@ -1,6 +1,17 @@
import 'dart:collection';
extension MapExtensions<A, B> on Map<A, B> {
Map<A, B> get deepCopy => {...this};
/// Returns the values of a [Map] at given [keys] indices.
Iterable<B> valuesByKeys({required Iterable<A> keys}) => keys.map((final key) => this[key]!);
}
extension LinkedHashMapExtensions<A, B> on LinkedHashMap<A, B> {
/// Updated the value at [valueIndex] to [newValue], in addition to preserving the order.
void updateValueAt({
required int valueIndex,
required B newValue,
}) =>
this[keys.toList()[valueIndex]] = newValue;
}

View file

@ -0,0 +1,5 @@
import 'package:flutter/cupertino.dart';
extension ValueNotifierBoolExtensions on ValueNotifier<bool> {
void flipValue() => value = !value;
}