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

@ -0,0 +1,26 @@
import 'package:flutter/widgets.dart';
import 'package:flutter_svg/flutter_svg.dart';
abstract class ConstMedia {
static const String favStarFilled = 'assets/icons/star_filled.svg';
static const String favStarOutline = 'assets/icons/star_outline.svg';
static SvgPicture buildIcon(
String iconReference, {
Color? color,
double? width,
double? height,
BoxFit fit = BoxFit.contain,
Clip clipBehavior = Clip.hardEdge,
Alignment alignment = Alignment.center,
}) =>
SvgPicture.asset(
iconReference,
color: color,
width: width,
height: height,
fit: fit,
clipBehavior: clipBehavior,
alignment: alignment,
);
}

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;
}