tryInline top-level constant Null safety

pragma const tryInline

An annotation for methods to request that dart2js always inline the method.

dart2js will attempt to inline the method regardless of its size. Even with this annotation, there are conditions that can prevent dart2js from inlining a method, including complex control flow.

import 'package:meta/dart2js.dart' as dart2js;

@dart2js.tryInline
String bigMethod() {
  for (int i in "Hello".runes) print(i);
}

It is an error to use both @noInline and @tryInline on the same method.

Implementation

const tryInline = pragma('dart2js:tryInline');