avoid_removed_fpdart_api
This rule flags fpdart names that were removed in 1.0.0 — Tuple2, Tuple3, the Predicate class, idFuture, concatMap, bindWithIndex and plus — in files that import fpdart.
Why use this rule
Section titled “Why use this rule”None of these compile against a 1.x fpdart, so the rule is aimed at migration rather than correctness: a codebase moving off 0.x, or a snippet copied from one of the many pre-2023 tutorials that still rank well in search results.
The value is the message. “Undefined name Tuple2” tells you something is wrong; “Tuple2 was removed in fpdart 1.0.0, use a Dart record” tells you what to do, without a trip to the changelog.
See also: fpdart changelog
final pair = Tuple2(1, 'a');final isOdd = Predicate<int>((n) => n % 2 == 1);final pair = (1, 'a'); // Dart records replaced Tuple2final isOdd = isEven.negate; // function extensions replaced PredicateThe full 1.0.0 removals: Tuple2/Tuple3 → records, Predicate → the function extensions (negate, and, or, contramap), id/idFuture → identity, concatMap/bind/bindWithIndex → flatMap, plus → concat, and the old concat → flatten.
Known limitations
Section titled “Known limitations”The rule only runs on files that import package:fpdart/. A removed name resolves to nothing, so without that gate the rule would fire on any unresolved identifier sharing the name — a project with its own Tuple2, or a plain typo in a file that has never heard of fpdart.
A name the project declares itself is not reported, since it resolves to that declaration.
bind and concat are not reported by default. They still exist in 1.x but mean different things than they did in 0.x, so copied code compiles and quietly does the wrong thing. A rule firing on a valid, current API is worse than the confusion it prevents — but a project mid-migration can add them through additional_removed.
Options
Section titled “Options”many_lints: rules: avoid_removed_fpdart_api: additional_removed: - bind - concatrules: avoid_removed_fpdart_api: additional_removed: - bind - concat| Option | Type | Default | Description |
|---|---|---|---|
additional_removed |
list of strings | [] |
Extra names to report. Unlike the built-in list these are reported even when they resolve, which is what makes bind/concat catchable during a migration |
Configuration
Section titled “Configuration”This rule is in the recommended preset, so it is on with
preset: recommended or preset: opinionated. Add it to preset: core with
avoid_removed_fpdart_api: true.
To turn it off:
rules: avoid_removed_fpdart_api: falseTo keep the rule on but skip certain paths, use per-rule exclude.
Related rules
Section titled “Related rules”avoid_ad_hoc_left_type— A pipeline only composes when every step shares one error type.avoid_bare_await_in_do— Awaiting a raw Future inside a Do block escapes the block’s tracking.avoid_dollar_outside_do_frame— Calling a Do block’s extraction function from a nested callback unwinds through code that cannot handle it.avoid_either_of_future— A Future nested in Either or Option escapes the error channel.