SkillAgentSearch skills...

Fpdart

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

Install / Use

/learn @SandroMaglione/Fpdart

README

<h3 align="center"> <a href="https://github.com/SandroMaglione/fpdart"> <img src="https://raw.githubusercontent.com/SandroMaglione/fpdart/main/resources/screenshots/screenshot_fpdart.png" width="500" /> </a> </h3> <p align="center"> <strong>Functional programming in Dart and Flutter</strong> </p> <p align="center"> All the main functional programming types and patterns <strong>fully documented</strong>, tested, and with examples </p> <h3 align="center"> <a href="https://docs.flutter.dev/packages-and-plugins/favorites"> <img src="https://raw.githubusercontent.com/SandroMaglione/fpdart/main/resources/flutter_favorite.png" width="120" /> </a> </h3> <p align="center"> <a href="https://github.com/SandroMaglione/fpdart"> <img src="https://img.shields.io/github/stars/SandroMaglione/fpdart?logo=github" /> </a> <img src="https://img.shields.io/github/contributors-anon/SandroMaglione/fpdart" /> <img src="https://img.shields.io/pub/v/fpdart?include_prereleases" /> <img src="https://img.shields.io/github/license/SandroMaglione/fpdart?logo=github" /> <a href="https://github.com/SandroMaglione"> <img alt="GitHub: SandroMaglione" src="https://img.shields.io/github/followers/SandroMaglione?label=Follow&style=social" target="_blank" /> </a> <a href="https://twitter.com/SandroMaglione"> <img alt="Twitter: SandroMaglione" src="https://img.shields.io/twitter/follow/SandroMaglione.svg?style=social" target="_blank" /> </a> </p>

Introduction

fpdart is fully documented. You do not need to have any previous experience with functional programming to start using fpdart. Give it a try!

fpdart is inspired by fp-ts, cats, and dartz.

Follow my Twitter for updates, or subscribe to the newsletter


fpdart v2.0.0

Version 2 of fpdart is currently in development. v2 is a rewrite based on a new Effect class, that aims to simplify the API and make it easier to use and learn.

You can learn more and follow the progress here.

fpdart v2 is planned to remain in pre-release stage because of some usability issues caused by limitations with the Dart language.

Meanwhile, fpdart is open for PRs if anyone is interested in contributing with improvements and bug fixes.

Read the full discussion here.


📖 Learn functional programming and fpdart

Would you like to know more about functional programming, fpdart, and how to use the package? Are you new to fpdart and functional programming?

👨‍💻 Getting started with fpdart complete guide

Interested in what fpdart is and how it came to be?

🚶 Full history of fpdart and functional programming in dart

✍️ Blog posts and tutorials

🧑‍🏫 Getting started with functional programming

💻 Installation

# pubspec.yaml
dependencies:
  fpdart: ^1.2.0

✨ Examples

fpdart + riverpod

Step by step course on how to build a safe, maintainable, and testable Flutter app using fpdart and riverpod.

Pokeapi

Flutter app that lets you search and view your favorite Pokemon:

  • API request
  • Response validation
  • JSON conversion
  • State management (riverpod)

Open Meteo API

Re-implementation using fpdart and functional programming of the Open Meteo API from the flutter_weather app example in the bloc package.

A 2 parts series explains step by step the Open Meteo API code:

Read/Write local file

Example of how to read and write a local file using functional programming.

Manage imports

Using fpdart with other libraries and noticing naming conflicts? Learn how to rename the classes that conflict with other SDK or third-party packages.

Option

Used when a return value can be missing.

For example, when parsing a String to int, since not all String can be converted to int

/// Create an instance of [Some]
final option = Option.of(10);

/// Create an instance of [None]
final none = Option<int>.none();

/// Map [int] to [String]
final map = option.map((a) => '$a');

/// Extract the value from [Option]
final value = option.getOrElse(() => -1);

/// Pattern matching
final match = option.match(
  () => print('None'),
  (a) => print('Some($a)'),
);

/// or use Dart's pattern matching as well 🤝
final dartMatch = switch (option) {
  None() => 'None',
  Some(value: final a) => 'Some($a)',
};

/// Convert to [Either]
final either = option.toEither(() => 'missing');

/// Chain computations
final flatMap = option.flatMap((a) => Option.of(a + 10));

/// Return [None] if the function throws an error
final tryCatch = Option.tryCatch(() => int.parse('invalid'));

Either

Used to handle errors (instead of Exceptions).

Either<L, R>: L is the type of the error (for exam

Related Skills

View on GitHub
GitHub Stars613
CategoryDevelopment
Updated3d ago
Forks51

Languages

Dart

Security Score

100/100

Audited on Mar 27, 2026

No findings