跪拜 Guibai
← All articles
Front-end · Android · Flutter

Dart Proposals Conditional Parts and `concrete` to End Cross-Platform Implementation Boilerplate

By 恋猫de小郭 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Flutter plugin and FFI developers currently juggle separate libraries, abstract classes, factories, and proxy layers to support multiple platforms; this proposal collapses that into a single class with platform `augment`s, and the analyzer guarantees no platform silently diverges from the agreed API.

Summary

Dart's language team has opened a draft PR (#4827) for conditional parts and a `concrete` modifier. Conditional parts let a `part` directive choose different implementation files based on the compilation target, just like conditional imports do today. The `concrete` keyword tells the analyzer that an abstract-looking method will actually have a body supplied by a platform-specific `augment`, so subclasses can call `super.close()` without error.

The proposal addresses a real pain point in Flutter plugins and FFI wrappers. With conditional imports, each platform implementation lives in a separate library, so private state like `_name` can't be shared, and nothing enforces API consistency across those files. Conditional parts keep everything in one library: `channel_io.dart` remains `part of 'channel.dart'`, can access private fields, and uses `augment` to fill in the method body. Each platform part can also import its own dependencies, like `dart:io`.

To keep static analysis deterministic, the proposal forbids conditional parts from adding new top-level declarations, new class members, `extends`/`implements`/`with` clauses, enum values, or changing parameter defaults. The analyzer checks the common public structure first, then validates that each platform's `augment` provides the required implementations. The author expects this to cut out abstract classes, factories, and proxy code for Flutter native/Web plugins, and to make FFI and JS interop wrappers far simpler.

Takeaways
— Dart PR #4827 is in draft status and proposes two changes: conditional `part` directives and a `concrete` modifier.
— Conditional parts work like conditional imports: a `part` line can pick different files based on `dart.library.io`, `dart.library.js_interop`, or other conditions.
— The `concrete` modifier lets the analyzer treat a method as non-abstract even when its body comes from a platform-specific `augment`, enabling `super.close()` calls.
— Platform part files remain in the same library as the main class, so they can access private fields and can each import their own platform dependencies.
— The proposal forbids conditional parts from adding top-level declarations, new class members, `extends`/`implements`/`with`, enum values, or changing parameter defaults, preserving identical public API structure across platforms.
— If the analyzer finds a missing or incomplete `augment` implementation for a chosen platform, compilation fails.
— Intended uses: Flutter native/Web plugins, FFI and JS interop wrappers, and code generation via augmentations.
Conclusions

The restriction table makes the trade-off explicit: platforms get to swap implementations but cannot extend the public shape of a class, which is exactly what enables the analyzer to check API consistency before platform selection happens.

The proposal mirrors Kotlin's expect/actual but avoids splitting the class declaration; instead of two separate declarations, Dart's `augment` modifies the same class, which keeps private state and type relationships in one place.

A `concrete` modifier is a clever reserve: it lets the analyzer infer existence of a method body without ever reading the conditional file, so subclasses can legally call `super` without a compile-time error on the common declaration.

Concepts & terms
Conditional Parts
A proposed Dart feature that lets a `part` directive choose implementation files based on compile-time conditions, mirroring the existing conditional `import` syntax.
concrete modifier
A new Dart modifier that declares a method has a real implementation provided by a platform-specific `augment`, even though the analyzer doesn't see the body in the common declaration. It permits calls like `super.close()` and triggers per-platform verification that the implementation exists.
augmentations
Dart's upcoming meta-programming mechanism that lets code modify or complete existing declarations from outside the defining library; here it's used to fill in method bodies for specific platforms.
From the discussion

Flutter's development progress is falling short of expectations, and the late arrival of these Dart proposals reinforces the doubt. The team's attention is split between Impeller bug fixes and AI work, pulling focus from core language evolution. At least one developer has already jumped to Electron, and the lateness of conditional-parts/concrete makes adoption enthusiasm questionable, especially as effort shifts to AI adaptation.

— Flutter's progress is slower than expected, and part of the reason is the team's focus on Impeller bugs and AI work.
— The conditional-parts and concrete proposal arrives years late, which casts doubt on how strongly the community will adopt it.
— One developer has already moved from Flutter desktop to Electron, signaling eroding confidence.
— Team energy is increasingly diverted to AI adaptation, further deprioritizing language-level features.
Featured comments
栈与烟火 1 likes

Honestly, Flutter's progress is much slower than expected.

恋猫de小郭

They're all working on Impeller bugs and AI.

栈与烟火  → 恋猫de小郭

I'm planning to switch from Flutter desktop to Electron.

茶树米

After so many years, they're only now doing this. It doesn't feel like there's much enthusiasm to follow up, is there?

恋猫de小郭

They've all gone off to do AI adaptation.

See top comments, translated →
Source: juejin.cn ↗ Google Translate ↗ Backup ↗