Closed
Description
Based on the converstation with Flutter users it seems that Flutter code it is common to guard large chunks of code behind runtime checks that boil down to:
if (Platform.isAndroid) {
// ...
}
(actual flutter code might be using a layer on top: see https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/foundation/platform.dart)
Here's a list of subtasks:
- Make
flutter build
/dart compile exe
/ ... tell VM's global analysis pass which operating system we compile for #50472 - Add mechanism to instruct VM's global analysis pass to try to const evaluate certain parts of a program before global analysis runs. #50473
- Make APIs in
package:platform
that wrapdart:io
/dart:html
and are amenable to tree shaking by compilers #50474 - Eventually we may add annotation of platform-specific code + warning mechanism if not guarded by platform checks to Dart language tools (CFE, Analyzer)
- Investigate whether above tree shaking mechanisms are sufficient for flutter plugin code.