list_ext 0.1.8 copy "list_ext: ^0.1.8" to clipboard
list_ext: ^0.1.8 copied to clipboard

outdated

Dart extension methods for Iterable and List. You can easily sum, count elements and many more.

list_ext #

pub package Dart CI

Dart extension method for Iterable and List.

Usage #

To use this plugin, add list_ext as a dependency in your pubspec.yaml file.

Than add import 'package:list_ext/list_ext.dart'; to the file for use extension methods.

Example #

import 'package:list_ext/list_ext.dart';

void main() {
  final list = [1, 2, 5];
  final sum = list.sum();
  print('Sum: $sum');
}

Methods classifier #

Common #

  • countWhere() - returns count of elements that satisfy the predicate.

Equality

  • isNullOrEmpty/isNotNullOrEmpty - check for null or empty.
  • isUnorderedEquivalent() - check equality of the elements of two iterables without considering order.
  • firstWhereOrNull() - return the first found element or null if no element found.

Safe elements access

  • tryElementAt() - returns the element at the index if exists or orElse if it is out of range.

Transformation #

  • reduceValue() - reduces values of elements in a collection to a single value by iteratively combining its using the provided function.

Iterables

  • chunks() - splits into chunks of the specified size.

String

  • joinOf() - get string value for each element and concatenates it with passed separator.

Map

  • toMap() - creates a Map instance from the iterable.

Math #

  • maxOf() - return max of values by elements.
  • minOf() - return min of values by elements.
  • sumOf()/sumOfDouble() - returns sum of values by elements.
  • avgOf()/avgOfDouble() - returns the average value of values by elements.

There are specific version of methods for Iterables of num (int and double):

  • max().
  • min().
  • sum().
  • avg().

List specific methods #

Transformation #

List

  • copyWith() - Copy current list with adding element.
  • copyWithAll() - Copy current list with adding all elements from another list.
39
likes
0
pub points
88%
popularity

Publisher

verified publisherinnim.ru

Dart extension methods for Iterable and List. You can easily sum, count elements and many more.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

collection, quiver

More

Packages that depend on list_ext