Functional extensions to Dart collections.

Overview

collection_ext

Pub Check Status Code Coverage MIT

A set of extension methods for Dart collections, designed for the purpose of making it easier to write concise, functional-programming-styled Dart code.

Working on an Iterable for example, with collection_ext, we can write:

iterable.forEachIndexed((i, x) => /* use index i & element x */)

instead of:

var i = 0;
for (var x in iterable) {
  // use index i & element x
  i++;
}

Usage

Import all extension methods at once:

import 'package:collection_ext/all.dart';

Column(
  children: getItems()
    .nonNull
    .mapIndexed((i, item) => Text("#$i ${item.title}"))
    .asList(),
)

Or you can import the needed module only, for example:

import 'package:collection_ext/iterables.dart';

final diff = [2, 4, 6].foldRight(0, (x, acc) => x - acc);

Nullability

All extension methods of Iterables & Maps are null-safe. For example:

Iterable itr;
assert(itr.sum() == 0);

Map map;
assert(map.none((k, v) => true) == true);

See nullability tests for more details.

Available Modules

👉 See API Docs for more details

I'm working on more useful extensions, PRs are welcome! 🍻 🖖

You might also like...

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

Jan 28, 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

Jan 3, 2023

Kenso - A fully functional social media app with multiple features built with flutter and dart

Kenso - A fully functional social media app with multiple features built with flutter and dart

Kenso - Social Media App Kenso is a fully functional social media app with multi

Feb 8, 2022

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

Dec 21, 2022

A fully functional social media app built with flutter with multiple features

A fully functional social media app built with flutter with multiple features

🔥 🔥 Wooble Social Media App Wooble is a fully functional social media app with multiple features built with flutter and dart. Star ⭐ the repo if you

Jan 3, 2023

A fully functional Movies Application built with Flutter. The application built with null safety and clean architecture, also uses OMDB API for fetching movies in the search item

A fully functional Movies Application built with Flutter. The application built with null safety and clean architecture, also uses OMDB API for fetching movies in the search item

Cinema DB Project Details This project uses null safety feature Project uses clean code architecture (Uncle Bob's Architecture) Project can run on bot

Oct 1, 2022

Fully Functional IOS/Android App for WordPress Website with Flutter

Fully Functional IOS/Android App for WordPress Website with Flutter

WordPress App with Flutter IOS/Android Native App for WordPress Website/Blog built using Flutter. No additional Plugins required for WordPress. Built

Dec 30, 2022

Open-source And Fully Functional Digital Signature App Built With Flutter

Open-source And Fully Functional Digital Signature App Built With Flutter

Open-source and fully functional digital signature app "E-Gol" 😽 Don't forget to star ⭐ the repo if you like what I have created 😉 . 📸 ScreenShots

Oct 19, 2022
Comments
  • Update Issue

    Update Issue

    I trying to update my packages and run into this Issue: Because every version of bluetooth_bloc from path depends on collection_ext 0.3.0 which depends on tuple ^1.0.3, every version of bluetooth_bloc from path requires tuple ^1.0.3. And because tuple >=1.0.2 <2.0.0-nullsafety.0 depends on quiver >=0.22.0 <3.0.0, every version of bluetooth_bloc from path requires quiver >=0.22.0 <3.0.0. And because google_sign_in >=5.0.1 depends on google_sign_in_platform_interface ^2.0.1 which depends on quiver ^3.0.0, bluetooth_bloc from path is incompatible with google_sign_in >=5.0.1. So, because elm_bluetooth_bloc depends on both google_sign_in ^5.0.3 and bluetooth_bloc from path, version solving failed. pub finished with exit code 1 Could u update Quiver and tuple references in your yaml, please. Also quiver is not mentioned as a dependency

    opened by ride4sun 0
Releases(v1.0.0)
Owner
Yingxin Wu
Software engineer, swimmer, scuba diver
Yingxin Wu
Immutable Dart collections via the builder pattern.

Built Collections for Dart Introduction Built Collections are immutable collections using the builder pattern. Each of the core SDK collections is spl

Google 250 Dec 20, 2022
A collections of packages providing additional functionality for working with bloc

Bloc Extensions A collections of packages providing additional functionality for working with bloc. Index Packages Bloc Hooks Action Blocs Contributin

Aljoscha Grebe 2 Apr 19, 2022
The Reactive Extensions for Dart

RxDart About RxDart extends the capabilities of Dart Streams and StreamControllers. Dart comes with a very decent Streams API out-of-the-box; rather t

ReactiveX 3.2k Dec 20, 2022
Enum extendable - Dart code generator. Generates enum extensions code.

Generates code for the extension on an enum. Overview Being able to add fields and methods to an enum. Let's say we have the following enum: enum Math

null 0 Jan 10, 2022
Extensions and principles for modern Dart development.

neodart Neo-Dart, or "new" Dart, is a series of recommended packages and principles that break out of classic conventions ("we've always done it that

Neo Dart 10 Dec 6, 2022
Awesome Flutter extensions to remove boilerplate

Awesome Flutter Extensions Awesome flutter extensions to remove boilerplate Installation Install using the Terminal: flutter pub add awesome_flutter_e

Alexandru Mariuti 3 Aug 20, 2022
Various extensions on BuildContext to access inherited widget's state

context_extentions Getting inherited widget's state var themeData = context.theme; var scaffold = context.scaffold; var navigator = context.navi

Ali Ghanbari 4 Sep 23, 2021
Material io ext - A collection of extensions for creating widgets following material.io guidelines

material_io_ext It is a collection of extensions for creating widgets following

BetterX.io 3 Jan 28, 2022
Package provides light widgets [for Linkify, Clean] and extensions for strings that contain bad words/URLs/links/emails/phone numbers

Package provides light widgets [for Linkify, Clean] and extensions for strings that contain bad words/URLs/links/emails/phone numbers

BetterX.io 4 Oct 2, 2022
(Full-stack) Fully functional social media app (Instagram clone) written in flutter and dart with backend node.js and Postgres SQL.

Photoarc A Fully functional social media app written in flutter and dart using node.js and Postgres SQL as backend. Backend Repository Demo Download t

Ansh rathod 59 Jan 5, 2023