Widgetbook 3.0 Generator Bug
Last active a month ago
10 replies
8 views
- AP
Hey y'all. I'm working on upgrading to v3 as well. I am using the generator, but it's no longer generating the main.widgetbook.dart file when building, instead I get the error
[SEVERE] widgetbook_generator:widgetbook_builder on lib/main.dart: Bad state: No element
I'm on versions
widgetbook: ^3.0.0-beta.5 widgetbook_annotation: 3.0.0-beta.3 widgetbook_models: ^3.0.0-beta.1 widgetbook_generator: ^3.0.0-beta.4
In main.dart I haven't changed the annotation code from the previous version:
@WidgetbookApp.material( name: 'rlly', devices: [ Apple.iPhone13Pro, Apple.iPhone12Mini, Samsung.s10, ], )
- AP
Verbose error:
Bad state: No element dart:core List.first package:widgetbook_generator/code_generators/instances/addons/text_scale_addon/text_scale_setting_instance.dart 20:57 new TextScaleSettingInstance package:widgetbook_generator/code_generators/instances/addons/text_scale_addon/text_scale_addon_instance.dart 13:25 new TextScaleAddonInstance package:widgetbook_generator/generators/app_generator.dart 66:14 generateWidgetbook package:widgetbook_generator/generators/widgetbook_generator.dart 70:9 WidgetbookGenerator.generateForAnnotatedElement
- AP
Here's my theme annotation in case that's relevant:
// Only used for widgetbook
@WidgetbookTheme(name: 'Light', isDefault: true)
ThemeData lightTheme() => ThemeData(
colorScheme: tealMagentaScheme,
primaryColor: const Color.fromRGBO(126, 110, 239, 1.0),
backgroundColor: const Color.fromRGBO(236, 0, 140, 1.0),
fontFamily: 'DM Sans',
canvasColor: RllyKnowledgeColors.background,
textTheme: textTheme); - JE
That looks like a bug that we haven’t fixed yet. You probably have no locales defined.
- JE
The generator should work without locales but for now you can define some placeholders
- AP
Thanks for the help. Happy new year!
I tried adding
@WidgetbookLocales() final locales = [ const Locale('en'), ];
to main.dart and am having the same issue
- AP
Looks like adding
textScaleFactors: [ 2, 3, 4, ],
to
@WidgetbookApp.material(
did the trick - AP
Oh, I think I'm running into the bug you were talking about now:
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ The following ProviderNotFoundException was thrown building Builder(dirty, dependencies: [_InheritedProviderScope?>]): Error: Could not find the correct Provider above this Builder Widget
I'll try adding localization annotations
- AP
That worked!
- AL
Widgetbook 3.0 Generator Bug
Last active a month ago
10 replies
8 views