Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/joutvhu/dart_utility
Dart Utility provides operations and functionality to dart.
https://github.com/joutvhu/dart_utility
dart extensions features funtions utility
Last synced: 4 days ago
JSON representation
Dart Utility provides operations and functionality to dart.
- Host: GitHub
- URL: https://github.com/joutvhu/dart_utility
- Owner: joutvhu
- License: mit
- Created: 2022-08-02T03:47:53.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-25T16:42:03.000Z (8 months ago)
- Last Synced: 2024-04-18T05:06:04.699Z (7 months ago)
- Topics: dart, extensions, features, funtions, utility
- Language: Dart
- Homepage: https://pub.dev/packages/dart_utility
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Dart Utility
Dart Utility provides operations and functionality to dart.
## Installation
```yaml
# Add into pubspec.yaml
dependencies:
dart_utility: ^1.0.1
``````dart
/// Import library (all utils)
import 'package:dart_utility/utility.dart';
```## Using
### DateTime Util
```dart
import 'package:dart_utility/date.dart';DateTime today = DateTimeUtil.today;
DateTime endOfToday = DateTimeUtil.endOfToday;
DateTime tomorrow = DateTimeUtil.next(1).startOfDay;
DateTime yesterday = DateTimeUtil.previous(1).startOfDay;
/// Compare DateTimes
assert(yesterday < today);
assert(yesterday < tomorrow);
assert(tomorrow > endOfToday);
assert(today <= endOfToday);/// To JSON (format "yyyy-MM-ddThh:mm:ss.SSSZ")
String json = today.toJson();
```### Iterable Util
```dart
import 'package:dart_utility/iterable.dart';/// Unique by Id
var uniqueProduct = [{'id': 1}, {'id': 2}, {'id': 1}]
.unique((e) => e['id']);/// Creates a slice of list from start up to, but not including, end.
var result = [1, 2, 3, 4].slice(2); // => [3, 4]var result = ['a', 'b', 'c', 'd'].chunk(2); // => [['a', 'b'], ['c', 'd']]
var result = [1, 2, 3].drop(2); // => [3]
var result = [1, 2, 3].dropRight(2); // => [1]
var result = [2, 1, 3, 4, 5].dropRightWhile((element) => element >= 3); // => [2, 1];
var result = [2, 1, 3, 4, 5].dropWhile((element) => element <= 3); // => [4, 5];
var isGrowable = list.isGrowable;
```### Async Util
```dart
import 'package:dart_utility/async.dart';var finishState = await store
.firstWhere((state) => state.type == 'finish' && state.name == 'test')
.execute(() => store.start('test'));
```