Skip to content

@Bind() generates $TextStyle references without import #121

@Treamz

Description

@Treamz

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions