Functional batteries for Dart programming language.

Overview

Pub Version codecov

Lightweight and practical functional library for Dart programming language.

The goal of this library is not having deep and hardcore FP features. If you need them, take a look at dartz package.

dfunc instead, provides some practical features based on FP principles, that we use extensively in our production codebase. We try to keep the library aligned with "Dart way" of doing things, instead of turning it into Haskell or Scala :)

Optional

There's no Optional type. Since nullsafety is introduced, nullable types cover the majority of use-cases for them. Instead, dfunc provides you some extensions for nullable types.

maybeMap and maybeFlatMap

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'
}

Both maybeMap and maybeFlatMap can be replaced with let if you prefer Kotlin-style:

void main() {
  String? x = null;
  x?.let((x) => x.toUpperCase()); // null

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

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

The differences are:

  • you don't need ?. with maybe* functions, they unwrap the value automatically;
  • you can enforce the function in maybeMap to return non-nullable result.

maybeWhere

Same as you can filter the list with where method to remove undesired values (and probably get an empty list), you can use maybeWhere to "filter" optional value. As a result you will get either the value itself, or null if the condition is not satisfied:

void main() {
  final List<int> a = [1];
  a.where((e) => e == 1); // [1]
  a.where((e) => e == 2); // []

  final int b = 1;
  b.maybeWhere((e) => e == 1); // 1
  b.maybeWhere((e) => e == 2); // null
}

Either

TBD

Utilities

TBD

Features and bugs

Please file feature requests and bugs at the issue tracker.

You might also like...

Random Users app, developed with Flutter and using Clean Architecture, BLoC, TDD and Functional Programming.

random_users This project is a sample of how to build a Flutter application using de benefits of Clean Architecture, TDD and Functional Programming. G

Jul 21, 2022

Dart package that converts number to words (English language)A Flutter/Dart package that converts number to words (English language)

flutter_number_to_words_english A Flutter/Dart package that converts number to words (English language) Flutter (Null Safety) Flutter (Channel stable,

Dec 9, 2022

Doing cool stuff with Git VCS in dart programming language.

Git Assistant Assists you to use git and .git in easy and simple way with robust API Features Generates git commands in simple form Supports commands,

Mar 4, 2022

This repository was created to provide the basics of the Dart programming language and Its use cases.

dart-exercises A collection of source code of the Dart Programming language. How does this repository works? Clone / Fork this repository to make your

Oct 28, 2021

Repo for Teach Yourself mastering dart programming language

mastering-dart Repo for Teach Yourself mastering dart programming language Chapter Membuat Aplikasi Pertama Menggunakan Dart Percabangan Perulangan Fu

Nov 10, 2022

App concept created with Flutter using Dart programming language, inspired by Groceries Shopping App Interaction.

App concept created with Flutter using Dart programming language, inspired by Groceries Shopping App Interaction.

Grocery Shop Flutter App concept created with Flutter using Dart programming language, inspired by Groceries Shopping App Interaction. About The app w

Dec 9, 2022

App concept created with Flutter using Dart programming language, inspired by Multi Search By Categories.

App concept created with Flutter using Dart programming language, inspired by Multi Search By Categories.

Photography Explorer Flutter App App concept created with Flutter using Dart programming language, inspired by Multi Search By Categories. About This

Sep 28, 2022

The component created with Flutter using Dart programming language, inspired in Fluid Slider by Ramotion.

The component created with Flutter using Dart programming language, inspired in Fluid Slider by Ramotion.

Fluid Slider Flutter The component created with Flutter using Dart programming language, inspired in Fluid Slider by Ramotion. About The component was

Sep 30, 2022

Machine learning algorithms in Dart programming language

Machine learning algorithms for Dart developers What is the ml_algo for? The main purpose of the library is to give native Dart implementation of mach

Jan 4, 2023

Flutter component concept created with Flutter using Dart programming language, inspired by Gooey Rab Bar.

Flutter component concept created with Flutter using Dart programming language, inspired by Gooey Rab Bar.

Gooey Tab Bar Flutter Flutter component concept created with Flutter using Dart programming language, inspired by Gooey Tab Bar. About This component

Dec 14, 2022

Implementation of data structures and algorithms in Dart programming language.

Algorithms in Dart Implementation of several algorithms with Dart programming language. Use dartdoc to generate documentation. Lists List data structu

Dec 24, 2022

A cross platform todo list app using flutter and dart programming language

A cross platform todo list app using flutter and dart programming language

Flutter Todos A cross platform todo list app using flutter and dart programming language. In this application, I used SQLite3 to persist data. The app

Dec 29, 2022

Weather-application - A weather application based on dart programming language

Weather-application - A weather application based on dart programming language

weather based mobile app A new Flutter project with dart programmingg language S

Nov 13, 2022

๐Ÿ‡ฎ๐Ÿ‡ช A generic programming language interpreter, linter, formatter, and all that jazz, written in Dart.

Irishman ๐Ÿ‡ฎ๐Ÿ‡ช A generic programming language interpreter, linter, formatter, and all that jazz, written in Dart. Installation To install this package

Oct 8, 2022

Fan-made, handmade, recursive-descent parser for the Dart programming language.

Very Unofficial Parser Fan-made, handmade, recursive-descent parser for the Dart programming language. Although this parser strives to parse the langu

Nov 21, 2022

Flutter language pickers2 - Language pickers package for Dart and Flutter

Flutter language pickers2 - Language pickers package for Dart and Flutter

language_pickers2 Notes: Original repository from github.com/gomgom, unfortunate

Feb 6, 2022

Native applications that are built with a specific programming language for a particular platform

Native applications that are built with a specific programming language for a particular platform

JAWABAN UAS 1.Aplikasi native adalah aplikasi yang dibangun dengan bahasa pemrograman yang spesifik untuk platform tertentu. Contoh populernya yakni p

Oct 16, 2021
Releases(v0.3.4)
Owner
Kirill Bubochkin
Mobile/Web developer. Head of Applications at Mews.
Kirill Bubochkin
Learn Dart with this cheat sheet

Learn Dart with this cheat sheet This project starts from Hello World untill the end of the Dart :) Simple example Hello World in Dart void main() {

null 28 Nov 11, 2022
Learn Dart with this cheat sheet

Learn Dart with this cheat sheet This project starts from Hello World untill the end of the Dart :) Simple example Hello World in Dart void main() {

AmirHossein Mohammadi 8 Jan 16, 2022
A Collection of Flutter and Dart Tips and Tricks

A Collection of Flutter and Dart Tips and Tricks

Vandad Nahavandipoor 5.7k Dec 27, 2022
Simple and easy-to-use Dart wrapper for HackerEarth API (Compile & Run)

HackerEarth API Simple and easy-to-use Dart wrapper for HackerEarth API which provides endpoints for compiling and running code in several languages.

Tirth 8 Dec 21, 2019
Functional programming in Dart and Flutter. All the main functional programming types and patterns fully documented, tested, and with examples.

Fpdart Functional programming in Dart and Flutter. All the main functional programming types and patterns fully documented, tested, and with examples.

Sandro Maglione 275 Dec 26, 2022
Functional programming essentials for Dart. Tail call optimization, partial application, memoization, and more.

Pure is a Dart package that brings functional programming essentials through extension methods. It offers function composition/pipes, function memoization, partial application, and recursion trampolines.

Yakov Karpov 10 Oct 27, 2022
Dartz - Functional programming in Dart

dartz Functional programming in Dart Type class hierarchy in the spirit of cats, scalaz and the standard Haskell libraries Immutable, persistent colle

Bjรถrn Sperber 680 Jan 3, 2023
Implementing Functional Programming concepts in Dart & Flutter.

Functional Programming in Dart The code is part of an Article series that demonstrates Functional Programming concepts in Dart & Flutter. Table of Con

Yogesh Parwani 13 Dec 21, 2022
Docker images for the Dart programming language (https://dart.dev)

dart-docker This is the Git repo of the Docker "Official Images" for the Dart programming language. See the Docker Hub page for a full description on

Dart 49 Dec 14, 2022
Dart port of FormCoreJS: A minimal pure functional language based on self dependent types.

FormCore.js port to Dart. So far only the parser and typechecker have been ported i.e. the FormCore.js file in the original repo. (Original readme fro

Modestas Valauskas 2 Jan 28, 2022