flutter_eval icon indicating copy to clipboard operation
flutter_eval copied to clipboard

TextStyle.copyWith not recognized inside eval → CompileError

Open Treamz opened this issue 3 months ago • 0 comments

When trying to use TextStyle.copyWith in evaluated code, the compiler throws an error saying that the method is unknown.

Minimal reproducible code:

abstract class AppThemeStyles {
  ThemeData get themeData;

  TextTheme get textTheme => themeData.textTheme;

  get smallBannerTitleSmall =>
      themeData.textTheme.titleSmall?.copyWith(color: colors.white);
}

Error log:

CompileError: Unknown method TextStyle.copyWith at "themeData.textTheme...." (file package:hot_part/theme/app_theme_styles.dart)
#0      resolveInstanceMethod (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:355:9)
#1      resolveInstanceMethod (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:360:14)
#2      resolveInstanceMethod (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:360:14)
#3      _invokeWithTarget (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:260:12)
#4      compileMethodInvocation.<anonymous closure> (package:dart_eval/src/eval/compiler/expression/method_invocation.dart:48:19)
...

Expected behavior:

TextStyle.copyWith should be available inside flutter_eval, since it’s a core Flutter method used for theming.

Actual behavior:

Compilation fails with Unknown method TextStyle.copyWith.

Treamz avatar Sep 15 '25 12:09 Treamz