functional_widget icon indicating copy to clipboard operation
functional_widget copied to clipboard

Throw if annotation is placed on methods instead of static functions

Open subzero911 opened this issue 4 years ago • 4 comments

It simply does not working (nothing generates).

That's my steps:

  • added part 'checkup_results_screen.g.dart'; (not mentioned in docs but I guess it is needed)
  • annotated my methods with @swidget image I also tried to remove underscore and build word.
  • it's unclear from the docs if I must pass context into function or not (I tried both)
  • run the build_runner

My pubspec: image I also tried to put functional_widget into dev_dependencies

subzero911 avatar Sep 04 '20 13:09 subzero911

From your screen shot, it appears that you decorated a method instead of a top-level function

Move the decorated method outside of the class and it should work

On Fri, Sep 4, 2020, 15:14 Sergey Molchanovsky [email protected] wrote:

It simply does not working (nothing generates).

That's my steps:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rrousselGit/functional_widget/issues/74, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEZ3I3JUEZJTCXBWOALO2H3SEDR43ANCNFSM4QYKVRTA .

rrousselGit avatar Sep 04 '20 13:09 rrousselGit

Yes, it actually does. I think it's worth mentioning in the manual. Because I broke all my head trying to understand the reason :)

subzero911 avatar Sep 04 '20 14:09 subzero911

I'll see if we can throw an error in that situation

rrousselGit avatar Sep 04 '20 14:09 rrousselGit

This finally helped solve my issue. I spent hours today trying to figure out why build_runner wouldn't find the files with @swidget in them. I looked in verbose output and the files with @swidget were not even being acted upon. I was using the annotation on a method in my class.

it wasn't clear from the docs that these methods should be moved outside of the class. If this warning cannot be accomplished in the build runner or annotation processing, it would be very helpful to spell this out in the docs.

If I missed it somewhere please show me where. Thanks.

menting311 avatar Jan 26 '24 19:01 menting311