field_
                  Fields in subclasses of 'Struct' and 'Union' can't have initializers.
Description
#
                    The analyzer produces this diagnostic when a field in a subclass of
                    Struct has an initializer.
                  
For more information about FFI, see C interop using dart:ffi.
Example
#
                    The following code produces this diagnostic because the field p has an
                    initializer:
                  
// @dart = 2.9
import 'dart:ffi';
final class C extends Struct {
  Pointer p = nullptr;
}
Common fixes
#Remove the initializer:
// @dart = 2.9
import 'dart:ffi';
final class C extends Struct {
  Pointer p;
}
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.