Share State Across Dart Isolates Without Losing Your Mind: Enter shared_map Dart engineer Graciliano M. Passos created package:shared_map, a synchronized Map data structure that lets Dart and Flutter developers share in-memory state across isolates without hand-rolling ReceivePort/SendPort plumbing. The library exposes a SharedMap on the main isolate, a serializable sharedReference() token passed into Isolate.run workers, and SharedMap.fromSharedReference() to reconstitute a proxy whose reads and writes sync back to the authoritative instance. This is Part 3 of the Dart and Flutter series—practical guides, architectural deep dives, and hard-earned engineering lessons from the field. Each article is completely standalone. Dart’s concurrency model is built on Isolates . Unlike threads in Java, C++, or Go, Dart isolates share no memory. Each isolate has its own private heap and its own single-threaded event loop. This "share-nothing" model is a brilliant design decision. It completely eliminates data races, deadlocks, mutex contention, and tricky thread-synchronization bugs. Until, of course, you actually need to share data across isolates. Imagine this common production scenario: You’re building a Flutter app that crunches heavy data in the background—perhaps resizing multiple images, decoding massive JSON payloads, computing cryptographic hashes, or running complex ML calculations. To keep your UI silky smooth at 120 FPS, you offload the work to background isolates using Isolate.run . Now suppose all these concurrent background workers need access to a shared, in-memory cache like parsed metadata, authentication tokens, or shared computation results to avoid duplicate work. How do you do that in Dart? Traditionally, you only had two bad choices: ReceivePort and SendPort . You have to invent custom request/response DTOs, generate unique request correlation IDs, wire up response completers, and write 150 lines of brittle plumbing just to perform a simple key-value lookup. There is a third, vastly superior option that almost nobody talks about: package:shared map https://pub.dev/packages/shared map . shared map ? Created by veteran Dart engineer Graciliano M. Passos, shared map provides a versatile, synchronized Map data structure designed specifically to be shared across Dart isolates and asynchronous workflows. Here is what makes it an architectural gem: get , put , putIfAbsent , and update . Instead of you manually orchestrating ports, shared map manages the cross-isolate communication protocol transparently under the hood. The core mental model of shared map is dead simple: SharedMap on your primary isolate like your Flutter UI thread or main server loop . This instance acts as the authoritative source of truth. .sharedReference to generate a lightweight, serializable token. Isolate.run . Inside the isolate, you reconstruct a proxy instance using SharedMap.fromSharedReference ref . Any reads, writes, or mutations performed by the worker isolate are automatically dispatched back to the main instance and synchronized across all isolates Let’s write a complete, self-contained example. We'll simulate multiple concurrent worker isolates crunching data, reading from a shared cache, and populating cache entries on the fly: import 'dart:isolate'; import 'package:shared map/shared map.dart'; void main async { // 1. Create a SharedStore and a SharedMap on the main isolate final store = SharedStore 'app cache' ; final userCache = await store.getSharedMap