fast_immutable_collections
Immutable lists, sets, maps, and multimaps, which are as fast as their native mutable counterparts. Extension methods and comparators for native Dart collections.
11.2.0
138K downloads/mo
#990 most downloaded on pub.dev
marcglasberg/fast_immutable_collections
What this package is like to depend on
Last release 4 months ago
14 Apr 2026
Release timing varies
gaps range from 9 days to 7 months
Rarely documented
notes for 20 of 100 stable releases
Nothing withdrawn
no release was ever pulled
6 years old
120 releases · first in 2021
2 releases in the last 12 months
see the full history below
Release timeline
120 releases · Jan 2021 to Apr 2026Releases
latest 60 of 120-
11.2.014 Apr 2026Release notes
Open source →-
Added
cachedmethod andCacheKeyclass for caching derived computations onIList,ISet, andIMap.Since immutable collections never change, any value derived from their contents is stable and can be safely cached. The new
cachedmethod lets you lazily compute and cache a derived value (like an index map) inside the collection instance itself, so subsequent calls return the cached result in O(1).Define a
CacheKey<C, R>that pairs a cache identity with a typed computation function. Usestatic finalor top-level variables for keys so the same object reference is reused across calls:class PairState { final IList<Pair> pairs; static final _byId = CacheKey<IList<Pair>, Map<Id, Pair>>( (list) => {for (var p in list) p.id: p}, ); Pair? findById(Id id) => pairs.cached(_byId)[id]; }The first call to
cachedbuilds the map in O(n) and caches it. Every subsequent call is O(1). When the collection is replaced with a new instance (e.g., an item is added), the old cache is garbage-collected with the old instance, and the new one builds its own cache on first access.Multiple cache keys can be used on the same collection, each caching independently:
static final _byId = CacheKey<IList<User>, Map<String, User>>( (list) => {for (var u in list) u.id: u}, ); static final _byEmail = CacheKey<IList<User>, Map<String, User>>( (list) => {for (var u in list) u.email: u}, );Notes:
- The cache adds zero overhead to collections that don't use it (a single null pointer).
- The cache survives
flush()since the collection identity is preserved. - Constant collections (
const IList.empty(),const IListConst(...), etc.) supportcachedbut compute the value each time without caching, since they cannot hold mutable state. CacheKeycan beconstwhen using a static or top-level function reference.
-
-
11.1.024 Oct 2025Release notes
Open source →- Added helper extension method
IList<IList<T>>.putXY()for setting values in
2D lists, using x,y coordinates.
- Added helper extension method
-
11.0.408 Apr 2025 -
11.0.306 Jan 2025Nothing published for this version
-
11.0.202 Jan 2025Nothing published for this version
-
11.0.101 Jan 2025Nothing published for this version
-
11.0.029 Oct 2024Nothing published for this version
-
10.2.429 May 2024 -
10.2.313 May 2024 -
10.2.201 Apr 2024Release notes
Open source →-
You can now declare empty lists, sets and maps like this (https://github.com/marcglasberg/fast_immutable_collections/pull/74):
const IList<String>.empty(); const ISet<String>.empty(); const IMap<String, int>.empty(); -
Better inference for sumBy returning zero (https://github.com/marcglasberg/fast_immutable_collections/pull/71).
-
-
10.2.122 Mar 2024Nothing published for this version
-
10.2.022 Mar 2024Nothing published for this version
-
10.1.208 Mar 2024Release notes
Open source →- Fixed https://github.com/marcglasberg/fast_immutable_collections/pull/71
-
10.1.114 Feb 2024Release notes
Open source →- Fixed https://github.com/marcglasberg/fast_immutable_collections/issues/69
-
10.1.028 Jan 2024Release notes
Open source →- Fixed https://github.com/marcglasberg/fast_immutable_collections/issues/68
-
10.0.025 Jan 2024 -
9.2.124 Jan 2024Release notes
Open source →- @useResult annotation to signal that a method should return a copy of the collection, instead of mutating it.
-
9.2.010 Nov 2023Nothing published for this version
-
9.1.608 Oct 2023 -
9.1.531 May 2023 -
9.1.329 May 2023Nothing published for this version
-
9.1.227 May 2023Nothing published for this version
-
9.1.127 Apr 2023 -
9.1.026 Apr 2023Nothing published for this version
-
9.0.026 Feb 2023 -
8.2.030 Jan 2023Release notes
Open source →IList.replaceBymethod lets you define a function to transform an item at a specific index location.
-
8.1.106 Jan 2023Release notes
Open source →IList.indexOfextension fix (doesn't break anymore when list is empty and start is zero).
-
8.1.027 Nov 2022 -
8.0.027 Oct 2022Release notes
Open source →- Breaking change:
IList.replaceFirstWheresignature is nowIList<T> replaceFirstWhere(bool Function(T item) test, T Function(T? item) replacement, {bool addIfNotFound = false})instead ofIList<T> replaceFirstWhere(bool Function(T item) test, T to, {bool addIfNotFound = false})In case this change breaks your code, the fix is simple. Instead of something likeilist.replaceFirstWhere((String item) => item=="1", "2")do this:ilist.replaceFirstWhere((String item) => item=="1", (_) => "2")
- Breaking change:
-
7.4.305 Oct 2022Nothing published for this version
-
7.4.219 Sep 2022Nothing published for this version
-
7.4.122 May 2022Nothing published for this version
-
7.4.020 May 2022Nothing published for this version
-
7.3.116 Apr 2022Nothing published for this version
-
7.2.114 Mar 2022Nothing published for this version
-
7.2.006 Feb 2022Nothing published for this version
-
7.1.331 Jan 2022Nothing published for this version
-
7.1.223 Dec 2021Nothing published for this version
-
7.1.123 Dec 2021Nothing published for this version
-
7.1.023 Dec 2021Nothing published for this version
-
7.1.0-dev026 Nov 2021 pre-releaseNothing published for this version
-
7.0.7-dev018 Oct 2021 pre-releaseNothing published for this version
-
7.0.6-dev009 Oct 2021 pre-releaseNothing published for this version
-
7.0.5-dev027 Sep 2021 pre-releaseNothing published for this version
-
7.0.319 Sep 2021Nothing published for this version
-
7.0.217 Sep 2021Nothing published for this version
-
7.0.117 Sep 2021Nothing published for this version
-
7.0.012 Sep 2021Nothing published for this version
-
6.0.005 Sep 2021Nothing published for this version
-
5.1.301 Sep 2021Nothing published for this version
-
5.1.219 Jul 2021Nothing published for this version
-
5.1.116 Jul 2021Nothing published for this version
-
5.0.527 Jun 2021Nothing published for this version
-
5.0.424 Jun 2021Nothing published for this version
-
5.0.324 Jun 2021Nothing published for this version
-
5.0.223 Jun 2021Nothing published for this version
-
5.0.107 Jun 2021Nothing published for this version
-
5.0.024 May 2021Nothing published for this version
-
5.0.0-dev.1311 May 2021 pre-releaseNothing published for this version
-
5.0.0-dev.1206 May 2021 pre-releaseNothing published for this version