-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|