dartx 0.2.0 copy "dartx: ^0.2.0" to clipboard
dartx: ^0.2.0 copied to clipboard

outdated

Superpowers for Dart. Collection of useful static extension methods.

example/main.dart

import 'package:dartx/dartx.dart';

void main() {
  var list = [0, 1, 2, 3, 4, 5];
  var last = list.slice(-1); // [5]
  var lastHalf = list.slice(3); // [3, 4, 5]
  var allButFirstAndLast = list.slice(1, -2); // [1, 2, 3, 4]

  var dogs = [
    Dog(name: "Tom", age: 3),
    Dog(name: "Charlie", age: 7),
    Dog(name: "Bark", age: 1),
    Dog(name: "Cookie", age: 4),
    Dog(name: "Charlie", age: 2),
  ];

  var sorted =
      dogs.sortedBy((dog) => dog.name).thenByDescending((dog) => dog.age);
  // Bark, Cookie, Charlie (7), Charlie (2), Tom

  var words = ['this', 'is', 'a', 'test'];
  var distinctByLength =
      words.distinctBy((it) => it.length); // ['this', 'is', 'a']

  var nestedList = [
    [1, 2, 3],
    [4, 5, 6]
  ];
  var flattened = nestedList.flatten(); // [1, 2, 3, 4, 5, 6]
}

class Dog {
  final String name;
  final int age;

  Dog({this.name, this.age});
}
909
likes
0
pub points
97%
popularity

Publisher

verified publishersimc.dev

Superpowers for Dart. Collection of useful static extension methods.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

characters, collection, crypto, path, quiver, time

More

Packages that depend on dartx