0 purchases
core extras
core_extras #
Provides a set of additional types, utilities and extensions to Dart core packages
Some examples are provided below.
Map Extensions #
valueOf #
Returns the value of the given key, if it exists, and adds it if it doesn't
final animalRatings = { "aardvark": 1, "baboon": 2 };
final aardvarkRating = animalRatings.valueOf("aardvark", initialValue: 0); // Returns existing value of 1
final baboonRating = animalRatings.valueOf("baboon", initialValue: 2); // Adds baboon and returns the value of 2
copied to clipboard
notContainsKey #
Whether this map does not contain the given key
final animalRatings = { "aardvark": 1, "baboon": 2 };
final notContainsAardvark = animalRatings.notContainsKey("aardvark"); // false
final notContainsCat = animalRatings.notContainsKey("cat"); // true
copied to clipboard
Rect Extensions #
inflateBySize #
Returns a new rectangle with all edges moved outwards by the given size
final rect = Offset.zero & const Size.square(100);
final inflated = rect.inflateBySize(const Size(50, 100));
// inflated.left = -50
// inflated.top = -100
// inflated.right = 150
// inflated.bottom = 200
copied to clipboard
expandBySize #
Returns a new rectangle with only the right and bottom edges moved outwards by the given size
final rect = Offset.zero & const Size.square(100);
final expanded = rect.inflateBySize(const Size.square(50));
// expanded.left = 0
// expanded.top = 0
// expanded.right = 200
// expanded.bottom = 200
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.