subtype_ of_ ffi_ class
The class '{0}' can't extend '{1}'.
The class '{0}' can't implement '{1}'.
The class '{0}' can't mix in '{1}'.
Description
#
The analyzer produces this diagnostic when a class extends any FFI class
other than
Struct
or
Union
, or implements or mixes in any FFI class.
Struct
and
Union
are the only FFI classes that can be subtyped, and
then only by extending them.
For more information about FFI, see C interop using dart:ffi.
Example
#
The following code produces this diagnostic because the class
C
extends
Double
:
import 'dart:ffi';
final class C extends Double {}
Common fixes
#
If the class should extend either
Struct
or
Union
, then change the
declaration of the class:
import 'dart:ffi';
final class C extends Struct {
@Int32()
external int i;
}
If the class shouldn't extend either
Struct
or
Union
, then remove any
references to FFI classes:
final class C {}
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.