flutter_eval icon indicating copy to clipboard operation
flutter_eval copied to clipboard

@Bind() generates $TextStyle references without import

Open Treamz opened this issue 3 months ago • 1 comments

The bindings generator creates calls to $TextStyle.wrap(...), but does not add the proper import/reference to the $TextStyle wrapper class. As a result, the analyzer/compiler fails with Undefined name '$TextStyle'.

Steps to Reproduce

  1. Define a class with @Bind() that extends TextTheme and overrides some properties:
@Bind()
class DemoTypography extends TextTheme with AppTypography {
  const DemoTypography();

  @override
  TextStyle get displayLG =>
      GoogleFonts.montserrat(fontSize: 28, fontWeight: FontWeight.w700);

  @override
  TextStyle get displayMD =>
      GoogleFonts.montserrat(fontSize: 24, fontWeight: FontWeight.w800);
}
  1. Run dart_eval bind and generate bindings.

  2. The generated code for $getProperty looks like this (excerpt):

case 'displayLG':
  final _displayLG = $value.displayLG;
  return $TextStyle.wrap(_displayLG);
  1. Compilation fails with: Error: Undefined name '$TextStyle'.

Expected Behavior

The generator should either:

Import the correct $TextStyle wrapper, or

Generate references that resolve correctly without manual fixes.

Actual Behavior

Code references $TextStyle without any import, leading to Undefined name '$TextStyle'.

Image

Treamz avatar Sep 12 '25 11:09 Treamz

and same problem with return $Color.wrap(_brand800);

Treamz avatar Sep 12 '25 13:09 Treamz