Skip to content
pubscout

kotlin_flavor

0.2.0, released 6 years ago by dartpkg.yusuke-iwaki.com

Provides Kotlin-familiar scope functions like let, run, and also for Dart.

WASM-ready
$ flutter pub add kotlin_flavor
Source repository

What it does

It implements Kotlin-like scope functions (let, run, also) as static extension methods in Dart. These functions help structure code blocks around objects, particularly handling null values and executing concise conditional expressions.

AI-written summary of version 0.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You want to use Kotlin-style scope functions such as let, also, and run in your Dart projects.
  • You need to execute code blocks conditionally on non-null values with clean syntax.

Skip it when

  • You prefer standard Dart control flow and null-aware operators without extension-based scope functions.
  • You require a large suite of Kotlin standard library utilities beyond let, run, and also.

Strengths

  • Brings familiar Kotlin scoping constructs to Dart.
  • Lightweight with no external dependencies.

Weaknesses

  • Very limited feature set consisting only of let, run, and also.
  • Not widely recognized or standard in the Dart ecosystem.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0

none

import 'package:kotlin_flavor/scope_functions.dart';

bool handle(Shop selectedShop) {
  return selectedShop?.let((shop) {
    navigateTo(shop.location);
    return true;
  }) ?? run(() {
    navigateToDefaultPosition();
    return false;
  });
}

Alternatives

Packages that do the same job and could replace kotlin_flavor.

  • extension_discovery

    Convention and utilities for discovering package extensions via config.yaml files.

  • gtk

    GTK utilities for Flutter Linux applications, providing settings and application lifecycle helpers.

  • mime

    Utilities to resolve MIME types from file names, magic bytes, and to parse multipart streams.

  • fast_immutable_collections

    Fast immutable lists, sets, maps, and multimaps for Dart