Short answer
Give the field its value where the object already exists. In a State class, assign it in initState, where widget is available. Or mark the field late so its initializer runs on first use (this works in a State class too, because widget is set by the time the field is first read), or move the value into the constructor body. If the value doesn’t depend on the instance, make the member it reads static.
Why the initializer can’t see the member, and the fix
01
A State field that reads widget
Field initializers run before the State is attached to its widget, so widget isn’t available there. Declare the field late and assign it in initState, and dispose it in dispose if it is a controller.
class _EditNameState extends State<EditName> { late final TextEditingController _controller; @override void initState() { super.initState(); _controller = TextEditingController(text: widget.initialName); } @override void dispose() { _controller.dispose(); super.dispose(); } }02
A field that reads another field
“When you mark a variable as late but initialize it at its declaration, then the initializer runs the first time the variable is used.” Dart, Variables: late variables
In a plain class, final total = price * quantity fails the same way. Mark the field late: the initializer then runs the first time the field is read, when the object exists. Use a getter instead if the value should follow later changes.
class Order { Order(this.price, this.quantity); final double price; final int quantity; late final double total = price * quantity; // runs on first use // or, always up to date: // double get total => price * quantity; }03
A constructor initializer list that calls a method
“If the member can be made static, then do so” Dart, implicit_this_reference_in_initializer
C() : x = defaultX fails when defaultX is an instance getter or method. If it doesn’t need the instance, make it static; otherwise compute the value in the constructor body or pass it in.
class C { int x; C() : x = defaultX; static int get defaultX => 0; }
Checked against the vendor’s docs on : Dart diagnostics: implicit_this_reference_in_initializer; Dart: Variables (late variables).
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.See scope and start
Related: Flutter “The parameter can’t have a value of null” · Flutter “Invalid constant value” · Flutter setState() called during build · Swift pods “cannot yet be integrated as static libraries”