functional_widget icon indicating copy to clipboard operation
functional_widget copied to clipboard

@cwidget not generating ConsumerWidget as expected

Open yuhao-nyc opened this issue 3 years ago • 3 comments

Describe the bug updating @swidget to @cwidget to generate a ConsumerWidget instead of StatelessWidget.

The build_runner is not generating for me for some reason. It's still StatelessWidget. Try to delete the g.dart file still getting the same StatelessWidget.

flutter_riverpod: ^0.14.0+3 functional_widget_annotation: ^0.9.0 functional_widget: ^0.9.0+1 in my local. Not sure what am I missing

To Reproduce

part 'test_widget.g.dart';

@cwidget Widget testWidget(BuildContext context) { return Container() }

Expected behavior A clear and concise description of what you expected to happen.

yuhao-nyc avatar May 04 '22 16:05 yuhao-nyc

I can confirm the bug. @cwidget is not working, in the the corresponding generated g.dart-file the created Widget inherits from Stateless Widget instead of ConsumerWidget. Thus, there is trouble finding the _ref argument in the build method.

fior-di-latte avatar May 24 '22 23:05 fior-di-latte

Just to add that for me, no matter what annotation, build runner always generates a Stateless Widget. functional_widget_annotation: ^0.10.0 functional_widget: ^0.10.0

itaispector avatar Jul 13 '22 00:07 itaispector

I had a dependency of freezed package. When I updated it to the latest version, it solves my issue.

itaispector avatar Jul 13 '22 01:07 itaispector