address_ position
The '.address' expression can only be used as argument to a leaf native external call.
Description
#
The analyzer produces this diagnostic when the
.address
getter is used
in a context other than as an argument to a native external call that is
marked as a leaf call (isLeaf: true
).
Example
#
The following code produces this diagnostic because
.address
is used
incorrectly:
import 'dart:ffi';
import 'dart:typed_data';
@Native<Void Function(Pointer<Uint8>)>()
external void nonLeafCall(Pointer<Uint8> ptr);
void main() {
final data = Uint8List(10);
// Incorrect: Using '.address' as an argument to a non-leaf call.
nonLeafCall(data.address);
}
Common fixes
#
Ensure that the
.address
expression is used directly as an argument to a
native external call that is annotated with
@Native(...)
and has
isLeaf: true
set in its annotation.
import 'dart:ffi';
import 'dart:typed_data';
@Native<Void Function(Pointer<Uint8>)>(isLeaf: true)
external void leafCall(Pointer<Uint8> ptr);
void main() {
final data = Uint8List(10);
// Correct: Using .address directly as an argument to a leaf call.
leafCall(data.address);
}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-4. View source or report an issue.