prefer-both-inlining-annotations
Warns when a @pragma('vm:prefer-inline') annotation does not have a corresponding @pragma('dart2js:tryInline') annotation.
info
Enable this rule only if you compile your code to JS and use inlining annotations.
⚙️ Config
Set suggest-wasm (default is false) to also suggest @pragma('wasm:prefer-inline').
analysis_options.yaml
dcm:
rules:
- prefer-both-inlining-annotations:
suggest-wasm: false
Example
❌ Bad:
// LINT: Missing a 'dart2js:tryInline' annotation. Consider adding it.
('vm:prefer-inline')
Future<String> bad() {
return Future.value('hello');
}
✅ Good:
('dart2js:tryInline')
('vm:prefer-inline')
Future<void> good() async {
return Future.value('hello');
}