Conditional imports or compilation
Have a way of not importing irrelevant packages in a flutter web config, or allow conditionnal imports without the need for stubs (ie conditional compilation flags).
import 'package:xxx-only_web_import/src/blob_url_empt.dart' if (dart.library.js_interop) 'src/blob_url.dart';
Yes but then I have to make stubs for every package not invoved in the web config. Would be better to be able to not compile the code in the config at all, like Delphi does with compiler defines.
Const if blocks?
void procedure<T>(T event) {
const if (dart.library.js_interop) {
// JS code.
} else {
// IO code.
}
}
Compile time code would be clearer as it can show exactly where the branch occurs and - on compilation - if the import is not used after compile time logic is computed then the imported code can be optimized out
Compile time code would be clearer as it can show exactly where the branch occurs and - on compilation - if the import is not used after compile time logic is computed then the imported code can be optimized out
Yep. When I look at my 10MB dart.js I see plenty of packages that are android-only mentionned. Since download size is a major concern for web apps optimizing this would be amazing.