Add sentinel libraries dart:cupertino and dart:desktop to allow for conditional imports in Flutter #49379
Labels
area-sdk
Use area-sdk for general purpose SDK issues (packaging, distribution, …).
type-enhancement
A request for a change that isn't a bug
Currently the only avaliable conditional import mechanics ("
dart:io
/dart:html
") works reliably only to differentiate for web and !web targets.As Flutter gained full desktop support I would ask to this being expanded to cover at least two additional target configurations, ie.
dart:cupertino
being avaliable for Apple's targets (macOS/iOS) anddart:desktop
being available for macOS/Linux/Windows/Fuchsia targets - also, or especially, in AOT mode.For Flutter ecosystem having just two (Cupertino/Material and Mobile/Desktop) knobs would allow developers to ship only platform relevant pieces compiled in.
Rationale: the conditional code preprocessing issue stays open for over 4 years now without a clear resolution in sight (what's understandable considering the scope). So while it would be better to have a kind of proper conditional compilation, or at least a kind of Go-style build constrains, reusing already present mechanics seems to be the least friction path.
Related: dart-lang/2133, dart-lang/1889, flutter/106950, flutter/23122.
The text was updated successfully, but these errors were encountered: