Skip to content
pubscout

dfunc

0.10.0, released 2 years ago by ookamikb.dev

Lightweight and practical functional programming features for Dart.

WASM-ready
$ flutter pub add dfunc
Source repository

What it does

Provides functional programming principles like Either, Result, and practical extensions for nullable types, iterables, and strings. It aims to stay aligned with the standard Dart workflow instead of deep hardcore FP features.

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

Use it when

  • You want practical functional helpers like Either, Result, or nullable extensions in your codebase.
  • You prefer lightweight functional utilities over heavy or complex FP libraries.

Skip it when

  • You need deep and hardcore functional programming features (use dartz instead).
  • You do not use functional programming patterns in your project.

Strengths

  • Lightweight and practical for production codebases.
  • Extensions for nullable types, strings, and iterables.
  • Aligns well with standard Dart idioms.

Weaknesses

  • Some sections like Either documentation are still marked as TBD in the README.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
void main() {
  String? x = null;
  x.maybeMap((x) => x.toUpperCase()); // null

  x = 'test';
  x.maybeMap((x) => x.toUpperCase()); // 'TEST'

  x.maybeFlatMap((x) => x == 'test' ? 'OK' : null); // 'OK'
}

Alternatives

Packages that do the same job and could replace dfunc.

  • dartz

    Pick dartz if you need deep and hardcore functional programming features.

Works with

Packages commonly used together with dfunc: ones it builds on, ones built on it, and its own family.