corextensions 0.0.1
corextensions: ^0.0.1 copied to clipboard

Many helpful extensions to the core classes like string and iterable.

Corextensions #

The extensions 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 returns true if an iterable has length 1.
  • Iterable.findSmallestWhere returns the smallest value in this iterable following a mapping to num.
  • Iterable.hasSameLengthAs returns true 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 returns true if the list has an element present more than once, checked by the equality operator ==.
  • List.swap swaps two elements within the list.
  • List.allIndicesOf returns all the indices of a value in the list.
  • Set.equals returns true if this set has the same values as the other set, in any order.
  • List<num>.sum returns the sum of the numbers.
  • List<num>.product returns the product of the numbers.
  • 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.

2
likes
100
pub points
1%
popularity

Many helpful extensions to the core classes like string and iterable.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

collection, trotter

More

Packages that depend on corextensions