dartx_nullsafety 0.6.0-nullsaftety.0 copy "dartx_nullsafety: ^0.6.0-nullsaftety.0" to clipboard
dartx_nullsafety: ^0.6.0-nullsaftety.0 copied to clipboard

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});
}
0
likes
60
pub points
0%
popularity

Publisher

unverified uploader

Superpowers for Dart. Collection of useful static extension methods.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

characters, collection, crypto, meta, path, time

More

Packages that depend on dartx_nullsafety