corextensions 1.1.1 corextensions: ^1.1.1 copied to clipboard
Many helpful extensions to the core classes like string and iterable.
Corextensions #
The corextensions package is made up of many extensions on core classes such as String
, List
and Iterable
.
Getting Started #
To import this package, include the following code:
import 'package:corextensions/corextensions.dart';
Example Properties #
For example, the following lists a few of these extensions:
Iterable.isSingle
returnstrue
if an iterable has length 1.Iterable.smallestWhere
returns the smallest value in this iterable following a mapping tonum
.Iterable.hasSameLengthAs
returnstrue
if the length of this iterable is the same as the other iterable provided.Iterable.count
returns the number of times a value is present in the iterable.List.mapWithIndex
returns an iterable which has been mapped using this list, where we are provided with both the value at the index, and the index itself.List.hasDuplicates
returnstrue
if the list has an element present more than once, checked by the equalityoperator ==
.List.swap
swaps two elements within the list.List.allIndicesOf
returns all the indices of a value in the list.Set.equals
returnstrue
if this set has the same values as the other set, in any order.Iterable.sumWhere
returns the sum of elements in the iterable following a function returning a number.String.capitalise
returns the string with the first letter replaced with the original one in upper case.String.removeExtraSpace
returns the string with whitespace removed from not just the start and the end, but also the middle, with the assumption that there should only be 1 space between 2 words.String.splitByAll
splits the string by all the delimiters provided.String.replaceLast
replaces the last occurence of a substring from the string.Map.firstValueWhere
returns the first value that satisfies the provided function.Map.reverse
flips keys and values.
On top of these, there is also the function zipTwoLists
which zips two lists in the provided order.
Examples using these properties can be found in the example section.
Documentation on the package can be found here.
Features and bugs #
To suggest additional properties or report bugs, report it here.