ffi_native_invalid_multiple_annotations
Native functions and fields must have exactly one @Native
annotation.
Description
#The analyzer produces this diagnostic when there is more than one Native
annotation on a single declaration.
Example
#The following code produces this diagnostic because the function f
has two Native
annotations associated with it:
dart
import 'dart:ffi';
@Native<Int32 Function(Int32)>()
@Native<Int32 Function(Int32)>(isLeaf: true)
external int f(int v);
Common fixes
#Remove all but one of the annotations:
dart
import 'dart:ffi';
@Native<Int32 Function(Int32)>(isLeaf: true)
external int f(int v);
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.