Iteo/theme_tailor

theme_tailor fails with flutter 3.3.0 (stable)

Closed this issue · 3 comments

Hi, thanks for this great package!

I'm getting an exception from theme_tailor when running the usual flutter packages pub run build_runner build --delete-conflicting-outputs, after upgrading to the latest flutter stable release (3.3.0). Downgrading to flutter 3.0.5 (without any other code changes) fixes the issue and build_runner again completes successfully.

I have a more complex theme template, but from the stacktrace it doesn't seem to be related to any particular thing in the template. Also, for me it is reproducible even with very simple template, e.g.

@Tailor(themes: ["light"], themeGetter: ThemeGetter.onBuildContext)
class _$AppColors {
  static List<Color> background = const [Color(0xFFFFFFFF)];
  static List<Color> onBackground = const [Color(0xFF3C3C3B)];
}

This is the error (obtained with appending --verbose to the mentioned build_runner command)

[SEVERE] theme_tailor:theme_tailor on lib/common/resources/tailor_theme_extensions.dart (cached):

Stack Overflow
dart:core                                                                    new _GrowableList.of
package:analyzer/src/dart/element/element.dart 4374:10                       LibraryElementImpl._partUnits
package:analyzer/src/dart/element/element.dart 4364:10                       LibraryElementImpl.units
package:analyzer/src/dart/element/element.dart 4348:22                       LibraryElementImpl.topLevelElements
dart:collection                                                              ListMixin.any
.                                                                            ...
.                                                                            ...
dart:collection                                                              ListMixin.any
package:theme_tailor/src/util/import_finder.dart 51:34                       ImportFinder._isExportedRecursivaly
dart:collection                                                              ListMixin.any
package:theme_tailor/src/util/import_finder.dart 51:34                       ImportFinder._isExportedRecursivaly
dart:collection                                                              ListMixin.any
package:theme_tailor/src/util/import_finder.dart 51:34                       ImportFinder._isExportedRecursivaly
dart:collection                                                              ListMixin.any
package:theme_tailor/src/util/import_finder.dart 51:34                       ImportFinder._isExportedRecursivaly
dart:collection                                                              ListMixin.any
package:theme_tailor/src/util/import_finder.dart 51:34                       ImportFinder._isExportedRecursivaly
dart:collection                                                              ListMixin.any
package:theme_tailor/src/util/import_finder.dart 51:34                       ImportFinder._isExportedRecursivaly
dart:collection                                                              SetMixin.any
package:theme_tailor/src/util/import_finder.dart 41:22                       ImportFinder.recursiveSearch
package:theme_tailor/src/util/extension/library_element_extension.dart 10:7  LibraryElementExtension.hasFlutterDiagnosticableImport
package:theme_tailor/src/generator/theme_tailor_generator.dart 48:36         ThemeTailorGenerator.generateForAnnotatedElement
package:source_gen/src/generator_for_annotation.dart 53:30                   GeneratorForAnnotation.generate
package:source_gen/src/builder.dart 352:33                                   _generate

[SEVERE] Build:
Failed after 132ms
[+4382 ms] "flutter pub" took 4,449ms.
[   +2 ms] pub finished with exit code 1
[        ] 
           #0      throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
           #1      _DefaultPub.interactively (package:flutter_tools/src/dart/pub.dart:418:7)
           <asynchronous suspension>
           #2      PackagesPassthroughCommand.runCommand (package:flutter_tools/src/commands/packages.dart:274:5)
           <asynchronous suspension>
           #3      FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1209:27)
           <asynchronous suspension>
           #4      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #5      CommandRunner.runCommand (package:args/command_runner.dart:209:13)
           <asynchronous suspension>
           #6      FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
           <asynchronous suspension>
           #7      AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #8      FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
           <asynchronous suspension>
           #9      run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
           <asynchronous suspension>
           #10     AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
           <asynchronous suspension>
           #11     main (package:flutter_tools/executable.dart:91:3)
           <asynchronous suspension>

Hey, thanks for the detailed report, temporarily you can use branch with the fix (change the dependency in the pubspec)

theme_tailor:
  git:
    url: https://github.com/Iteo/theme_tailor.git
    path: packages/theme_tailor
    ref: fix/#38

I can confirm that fix/#38 resolved the issue for me as well!
Thanks very much, that was super quick! 👏

Fixed in theme tailor 1.0.6