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/FpdartREADME
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.
- Introduction
- 📖 Learn
functional programmingandfpdart - 💻 Installation
- ✨ Examples
- 🎯 Types
- 💡 Motivation
- 🤔 Roadmap
- 📃 Versioning
- 😀 Support
- 👀 License
📖 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
- Option type and Null Safety in dart
- Either - Error Handling in Functional Programming
- Future & Task: asynchronous Functional Programming
- How to use TaskEither in fpdart
- How to make API requests with validation in fpdart
- How to map an Either to a Future in fpdart
- Flutter Supabase Functional Programming with fpdart
- fpdart, Functional Programming in Dart and Flutter
- How to use fpdart Functional Programming in your Dart and Flutter app
- Pure Functional app in Flutter – Pokemon app using fpdart and Functional Programming
🧑🏫 Getting started with functional programming
- Functional Programming Option type – Introduction
- Chain functions using Option type – Functional Programming
- Practical Functional Programming - Find repeated characters | Part 1
- Pure Functions - Practical Functional Programming | Part 2
- Immutability – Practical Functional Programming | Part 3
- Loops using fold – Practical Functional Programming | Part 4
- Maybe | Practical Functional Programming
- 5 Lessons from Functional Programming in Scala, By Paul Chiusano and Runar Bjarnason
💻 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:
- Open Meteo API - Functional programming with fpdart (Part 1)
- Open Meteo API - Functional programming with fpdart (Part 2)
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
Stringtoint, since not allStringcan be converted toint
/// 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>:Lis the type of the error (for exam
Related Skills
node-connect
341.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.6kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.6kCommit, push, and open a PR
