Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yusukeiwaki/dart-kotlin_flavor
https://github.com/yusukeiwaki/dart-kotlin_flavor
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/yusukeiwaki/dart-kotlin_flavor
- Owner: YusukeIwaki
- License: mit
- Created: 2019-11-02T05:55:42.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-01T11:38:43.000Z (almost 4 years ago)
- Last Synced: 2024-10-07T15:04:03.248Z (3 months ago)
- Language: Dart
- Size: 23.4 KB
- Stars: 30
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[![Dart CI](https://github.com/YusukeIwaki/dart-kotlin_flavor/workflows/Dart%20CI/badge.svg)](https://github.com/YusukeIwaki/dart-kotlin_flavor/actions?query=workflow%3A"Dart+CI") [![Pub](https://img.shields.io/pub/v/kotlin_flavor)](https://pub.dev/packages/kotlin_flavor)
# kotlin_flavor
Are you Android-app engineer, and eager to use scope functions also in Dart?
Yes, `kotlin_flavor/scope_functions` provides it for you! :)
```dart
import 'package:kotlin_flavor/scope_functions.dart'bool handle(Shop selectedShop) {
return selectedShop?.let((shop) {
navigateTo(shop.location);
return true;
}) ?? run(() {
navigateToDefaultPosition();
return false;
});
}
```## kotlin_flavor/scope_functions
### let
Often used for executing a code block only with non-null values.
```
someNullable?.let((it) { ... });
```### also
Used for additional actions that don't alter the object, such as logging or printing debug information.
```
something.also((it) { ... }); // returns something.
```### run
Used for evaluating a block of several statements where an expression is required.
```
someNullable ?? run(() {
var defaultValue = ......;
// several process...return defaultValue;
});
```## Development
```
$ docker-compose pull
$ docker-compose run --rm dart
```will build a Dart development environment for you.
Ensure all test successfully pass, every after you change some codes:
```
$ pub run test
```