Add information about how platform-specific Dart code can be guarded so that it is appropriately tree-shaken in release applications #11666
Labels
co.request
Community ask for documentation
d.enhancement
Improves docs with specific ask
dev.integration
Relates to platform integration
p1-high
Major but not urgent concern: Resolve in months. Update each month.
t.performance
Relates to performance tuning and optimization
What information needs to be added?
Would it be possible to say somewhere that code guarded with checks against
defaultTargetPlatform
, e.g.,or
are appropriately tree-shaken in release builds of Flutter applications (and so dependencies used only in code guarded by such checks should also be tree-shaken, etc.)?
Where should this new content appear?
Currently it looks like the only examples of code using
defaultTargetPlatform
are in https://docs.flutter.dev/platform-integration/macos/platform-views and https://docs.flutter.dev/platform-integration/ios/platform-views, and https://docs.flutter.dev/platform-integration/platform-channels only mentionsdefaultTargetPlatform
in a sidebar, so I'm unsure if those are the right places or not, or if this should be relegated to thedefaultTargetPlatform
/TargetPlatform
API docs.See dart-lang/sdk#31969 (comment) for the original request, and see flutter/flutter#14233 (comment) for more background. Let me know if there's anything I can do to help, or if there's some place I should file this instead. Thanks!
I would like to fix this problem.
The text was updated successfully, but these errors were encountered: