isAssignable property
A function that determines if a native value can be assigned to this bridged type.
This is used when bridging native values back to the interpreter. When a native
method returns an instance of a private subclass (e.g., _Linear extends Curve),
the bridge lookup by exact type will fail. This function allows the runtime to
find an appropriate supertype bridge by checking isAssignable(nativeValue).
Example for Curve bridge:
BridgedClass(
nativeType: Curve,
isAssignable: (v) => v is Curve,
...
)
When Curves.linear returns a _Linear instance, the runtime will:
- Try exact type lookup for
_Linear- fails (not registered) - Iterate through registered bridges, checking
isAssignable - Find the
Curvebridge where_Linear() is Curvereturns true - Wrap the
_Linearinstance using theCurvebridge
Implementation
final bool Function(Object?)? isAssignable;