Dart vs FxDart
The same real task, solved twice: plain Dart on the left, FxDart on the right. Both versions run in your browser and print exactly the same output — compare them and decide for yourself.
A word of honesty before the list: Dart's built-in Iterable
is already lazy, and simple where/map chains
are perfectly good Dart. FxDart is not here to beat those. What it adds
is vocabulary
(groupBy,
chunk,
zip,
scan,
uniqBy,
partition —
things core Dart makes you hand-roll),
composition (one typed
fx() chain instead
of nested calls and intermediate variables), and above all
concurrency control —
.concurrent(n) runs an
async pipeline n items at a time, in order, which plain Dart can only
approximate with manual worker pools. Every example carries a verdict
badge, and some of them say native Dart is fine. That's the point: when
an example does say FxDart wins, you can believe it.
FxDart wins — clearly better here · Toss-up — equally good, pick by taste · Native is fine — plain Dart handles it well · async — uses async pipelines
Two standpoints per example: the filled badge judges the code — which version is nicer to write and read. The outlined ⚡ badge reports the measurement — the wall-clock winner at the largest benchmarked size, AOT-compiled; each page's Benchmark section has the full bars.
If you only read five, read these: #1 Top 3 largest expenses · #11 Top 5 merchants by total spend · #23 Enrich top merchants concurrently · #31 Multi-currency expense report · #53 Price drops between two snapshots
Part 1 · Two functions
Everyday one-liners. Native Dart often keeps up here — watch the verdict badges.
- 1 Top 3 largest expenses Toss-up ⚡ FxDart faster Largest three transactions of the month — sortedBy + take from package:collection vs sortBy + take in FxDart.
- 2 Most frequent log level FxDart wins ⚡ FxDart faster Count log entries per level and pick the biggest — groupListsBy + reduce in plain Dart vs countBy + maxBy in FxDart.
- 3 Load three remote configs in order FxDart wins async ⚡ Same speed Sequential async fetches — a plain await-in-loop in Dart vs toAsync + map in FxDart, one word away from bounded concurrency.
- 4 Average order value over $100 Toss-up ⚡ FxDart faster Mean total of large orders — where/map/average with package:collection vs filter + averageBy in FxDart.
- 5 Batch users into pages of 10 FxDart wins ⚡ FxDart faster Split a user list into fixed-size pages — slices from package:collection vs chunk + map in FxDart.
- 6 Rank labels for a leaderboard Toss-up ⚡ Same speed Number a sorted leaderboard 1..n — Dart 3 indexed records vs zipWithIndex + map in FxDart.
- 7 Running account balance FxDart wins ⚡ Native faster Balance after every transaction — a mutable accumulator loop in plain Dart vs scan + map in FxDart.
- 8 Food spending this month FxDart wins ⚡ FxDart faster Total one category of a ledger — a where/fold chain in plain Dart vs filter + sumBy in FxDart.
- 9 Merchants in first-visit order FxDart wins ⚡ Native faster Order-preserving dedupe — a seen-set loop in plain Dart vs map + uniq in FxDart.
- 10 First sensor reading over the limit Native is fine ⚡ Same speed Find the first temperature above a threshold — skipWhile + firstOrNull in plain Dart vs dropWhile + head in FxDart.
Part 2 · Three functions
Vocabulary native Dart lacks starts to pay off: groupBy, uniqBy, partition, scan.
- 11 Top 5 merchants by total spend FxDart wins ⚡ FxDart faster Group a ledger by merchant and rank the totals — groupListsBy + sortedBy in plain Dart vs one groupedBy → sortByDesc → take chain in FxDart.
- 12 All tags across posts, sorted Toss-up ⚡ FxDart faster Flatten post tags into one sorted, distinct list — expand + toSet + sort in plain Dart vs flatMap + uniq + sort in FxDart. A tie on the page, 1.5× on the clock.
- 13 Refunds vs charges, both formatted FxDart wins ⚡ FxDart faster Split a ledger into refunds and charges and print both sides — two where passes in plain Dart vs one partition in FxDart.
- 14 First 5 valid emails, normalized Native is fine ⚡ FxDart faster Trim, lowercase, validate, take five — map/where/take in plain Dart vs map + filter + take in FxDart. Plain Dart is every bit as clean here.
- 15 Fetch profiles, two at a time FxDart wins async ⚡ Native faster Bounded, in-order concurrency — a hand-rolled worker pool in plain Dart vs toAsync + map + concurrent in FxDart.
- 16 Compound interest table FxDart wins ⚡ Native faster A year-by-year balance table at 5% — a mutating accumulator loop in plain Dart vs range + scan + map in FxDart.
- 17 Category with highest average expense FxDart wins ⚡ Native faster Group expenses and find the priciest category per transaction — collection groupBy + maxBy nested calls in plain Dart vs one FxDart chain.
- 18 Spending inside a date window Toss-up ⚡ FxDart faster Sum a slice of a date-sorted ledger — skipWhile/takeWhile/fold in plain Dart vs dropWhile + takeWhile + sumBy in FxDart. Native holds up well.
- 19 Pair sensors with readings, keep anomalies FxDart wins ⚡ Native faster Join two parallel lists and flag hot readings — an index loop in plain Dart (core has no zip) vs zip + filter + map in FxDart.
- 20 Recent error messages, deduped FxDart wins ⚡ Native faster The three most recent distinct errors from a newest-first log — a seen-Set loop with a break in plain Dart vs filter + uniqBy + take in FxDart.
Part 3 · Five functions
Real reports and pipelines — where composition keeps multi-step logic readable.
- 21 Detect duplicated transactions FxDart wins ⚡ Same speed Flag charges with the same merchant, amount, and day — putIfAbsent plus nested loops in plain Dart vs groupBy + filter + flatMap in FxDart.
- 22 Longest streak of no-spend days FxDart wins ⚡ Same speed Longest run of July days with no transaction — loop with streak/longest counters in plain Dart vs range + scan + max in FxDart.
- 23 Enrich top merchants concurrently FxDart wins async ⚡ Native faster Pick the top 3 merchants, then look each up over a rate-limited API, 2 at a time — a hand-rolled worker pool in plain Dart vs concurrent(2) in FxDart.
- 24 Leaderboard with tied ranks FxDart wins ⚡ FxDart faster Rank players so equal scores share a rank — mutable rank/prevScore state in plain Dart vs sortBy + groupBy + zipWithIndex in FxDart.
- 25 Weekly averages from daily readings FxDart wins ⚡ Same speed Fold 21 daily readings into 3 weekly averages — index arithmetic and sublist in plain Dart vs chunk + averageBy + zipWithIndex in FxDart.
- 26 Paginated product listing Toss-up ⚡ Native faster Filter, sort by price, and slice out page 2 — Dart already has skip/take, so this one is a genuine tie.
- 27 Line items to invoice summary FxDart wins ⚡ FxDart faster Turn order line items into per-category totals plus a grand total — two loop-and-fold idioms in plain Dart vs groupBy + sumBy + sortBy in FxDart.
- 28 Categories over their monthly budget FxDart wins ⚡ FxDart faster Total spend per category, keep the ones over budget, rank by overage — mutable-map bookkeeping in plain Dart vs groupBy + filter + sortBy in FxDart.
- 29 Monthly category report, sorted by spend FxDart wins ⚡ Native faster Filter a ledger to one month, total each category, and rank them — loop plus mutable map in plain Dart vs filter + groupBy + sortBy in FxDart.
- 30 Three consecutive readings over the limit FxDart wins ⚡ Native faster Find every 3-hour window of CO2 readings all over 1000 ppm — an index loop in plain Dart vs a sliding window built from zip3 + drop in FxDart.
Part 4 · Six to ten functions
Full workflows, most with bounded concurrency — the part native Dart cannot express cleanly.
- 31 Multi-currency expense report FxDart wins ⚡ FxDart faster Normalize a trip ledger to USD with fixed rates, then group, rank, and summarize — one pipeline per report line vs fold/reduce boilerplate.
- 32 Inventory restock plan FxDart wins ⚡ FxDart faster Prioritize below-threshold items and cut the order list at a budget — scan + zip + takeWhile as data flow vs a mutable running total and break.
- 33 Concurrent price lookup with fallback FxDart wins async ⚡ Same speed Look up live prices 3 at a time, fall back to catalog prices for missing SKUs — concurrent + a null-coalescing map vs a worker pool.
- 34 Full monthly ledger report FxDart wins ⚡ FxDart faster One report string from a ledger — total, category breakdown, top merchants — as three fxdart pipelines vs loops and intermediate maps.
- 35 Fill gaps in a sparse time series FxDart wins ⚡ FxDart faster Days with no transactions become 0.00, then weekly rows with totals — range + groupBy + chunk as one flow vs a counting loop and slices.
- 36 Parallel downloads, results in order FxDart wins async ⚡ Native faster Six downloads with different speeds, 3 at a time — concurrent keeps request order even when completions interleave, vs pool bookkeeping.
- 37 Diff two ledger snapshots FxDart wins ⚡ Native faster Added, removed, and unchanged entries between two snapshots — differenceBy and intersectionBy by id vs hand-built id sets and where filters.
- 38 Poll a flaky API until first success FxDart wins async ⚡ Native faster Retry-until-ready as a lazy pipeline — range + toAsync + map + dropWhile + head vs an imperative polling loop with a break.
- 39 Log alert digest by service and severity FxDart wins ⚡ Same speed WARN and ERROR logs rendered as an indented digest — nested grouping via groupBy + flatMap + uniq vs three nested loops and a seen-set.
- 40 p50/p95 latency per endpoint FxDart wins ⚡ Same speed Percentile table from raw request logs — groupBy + sortBy + nth per endpoint vs a row-accumulating loop with in-place sorts.
- 41 Two paged feeds, concatenated and deduped FxDart wins async ⚡ Native faster Drain a primary log store, then its replica, dedupe by id, stop at 8 — concat + uniqBy + take stays lazy, vs nested loops with a seen-set.
- 42 Anomalies with surrounding context FxDart wins ⚡ FxDart faster Show over-limit sensor readings plus one line before and after — zipWithIndex + flatMap + uniq as one pipeline vs an index set built in nested loops.
- 43 Smoothed zone changes FxDart wins ⚡ FxDart faster Moving average, zone runs, transition alerts — three index loops with mutable carry in plain Dart vs windowed → uniqAdjacentBy → pairwise in FxDart.
- 44 Windowed alerts from a sensor stream FxDart wins async ⚡ Native faster Chunk a real Dart Stream into fixed windows and raise alerts — fromStream + chunk + averageBy vs manual buffer bookkeeping in await-for.
- 45 Live search over a keystroke stream FxDart wins async ⚡ Native faster Turn a stream of keystrokes into deduped backend searches — fromStream + filter + uniq + take + map vs await-for with guard clauses.
- 46 Rate-limited batch import FxDart wins async ⚡ Native faster Import 9 transactions in batches of 3, one batch at a time, with a running total — chunk + concurrent(1) + scan vs a sequential loop.
- 47 Rank the month by category FxDart wins ⚡ Same speed Group, total, and rank spending — groupListsBy plus a comparator swap in plain Dart vs one groupedBy → sortByDesc chain in FxDart.
- 48 Revalue the stock, three lookups at a time FxDart wins async ⚡ Native faster Live price lookups with a fallback — a worker pool plus hand-built pairs in plain Dart vs attach + concurrent + countWhere in FxDart.
- 49 Fetch 10 profiles, 3 at a time FxDart wins async ⚡ Same speed Sync prep flowing straight into bounded concurrency — filter and sort, then toAsync + map + concurrent(3), vs a hand-rolled worker pool.
- 50 Cohort retention table FxDart wins ⚡ Same speed Signup-month cohorts vs later activity — nested groupBy/dropWhile/filter pipelines vs nested for loops with accumulator lists.
- 51 Finale — DailyLedger monthly close FxDart wins async ⚡ Same speed The finale: load ledger entries 3 at a time, then compute the July summary and category breakdown — the real DailyLedger app shapes, both ways.
- 52 End-of-day settlement pipeline FxDart wins async ⚡ FxDart faster Validate, group by merchant, post 2 at a time, then report — one chain crossing sync to async, vs groupListsBy plus a worker pool.
- 53 Price drops between two snapshots FxDart wins ⚡ FxDart faster Compare two price-list snapshots and report what got cheaper — indexBy + filter + sortBy + head + sumBy vs a map literal and where/fold chains.