Skip to content

Commit

Permalink
v0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
simc committed Oct 27, 2019
1 parent f6dd48a commit 880a2b2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dartx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var slice = [1, 2, 3, 4, 5].slice(1, -2); // [2, 3]
### slice()
Returns elements at indices between `start` (inclusive) and `end` (inclusive).
```dart
var list = [0, 1, 2, 3, 4, 5]);
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]
Expand Down
37 changes: 37 additions & 0 deletions dartx/example/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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});
}
2 changes: 1 addition & 1 deletion dartx/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dartx
description: Superpowers for Dart. Collection of useful static extension methods.
version: 0.1.1
version: 0.1.2
author: Simon Leier <[email protected]>
homepage: https://github.com/leisim/dartx

Expand Down

0 comments on commit 880a2b2

Please sign in to comment.