https://github.com/alexcmgit/dart-shared-tools
A set of Dart tools that I often use in my projects (no Flutter dependency).
https://github.com/alexcmgit/dart-shared-tools
Last synced: about 1 year ago
JSON representation
A set of Dart tools that I often use in my projects (no Flutter dependency).
- Host: GitHub
- URL: https://github.com/alexcmgit/dart-shared-tools
- Owner: alexcmgit
- License: mit
- Created: 2022-08-20T14:53:23.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-12-06T19:59:00.000Z (over 3 years ago)
- Last Synced: 2025-04-03T14:22:05.791Z (about 1 year ago)
- Language: Dart
- Homepage:
- Size: 34.2 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## How to install
(Recommended) Fork and depend of your fork instead using this one. This is a really unstable installation since it's not from _pub.dev_.
```yaml
dependencies:
# ...
dart_shared_tools:
git:
url: https://github.com/alexrintt/dart-shared-tools
ref: master
# ...
```
And use as:
```dart
import 'package:dart_shared_tools/dart_shared_tools.dart';
```
## Features
Check out full list of features.
### Available extensions
- `ApplyIfNotNull`.
```dart
// Single line solution:
someNullValue?.apply((T value) => executeOnlyIfItsNotNull(value)) ?? otherwise();
// Instead of:
if (someNullValue != null) {
executeOnlyIfItsNotNull(someNullValue!);
} else {
otherwise();
}
```
### Utilities
- _Sem Ver_ masking function. Useful to work with database versions (Which accepts only integers).
```dart
maskVersion('v0.1.0'); // 256
unmarkVersion(256); // 'v0.1.0'
```
### Constants
- DP constants.
```dart
const double k0dp = 0 * 2.0;
const double k1dp = 1 * 2.0;
const double k2dp = 2 * 2.0;
const double k3dp = 3 * 2.0;
const double k4dp = 4 * 2.0;
const double k5dp = 5 * 2.0;
const double k6dp = 6 * 2.0;
const double k7dp = 7 * 2.0;
const double k8dp = 8 * 2.0;
const double k9dp = 9 * 2.0;
// ...available up to [k40dp]
```
Open Source
Copyright © 2022-present, Alex Rintt.
Dart Shared Tools is MIT licensed 💖