rrousselGit / functional_widget

A code generator to write widgets as function without loosing the benefits of classes.
597 stars 46 forks source link

Code not generated when using builder #56

Closed PiN73 closed 4 years ago

PiN73 commented 4 years ago

According to Install (builder) in readme, I added dependencies in pubspec.yaml

dependencies:
  flutter:
    sdk: flutter
  functional_widget_annotation: ^0.5.1

builders:
  functional_widget: ^0.7.1

and made a simple widget

@widget
Widget foo(BuildContext context, int value) {
  return Text('$value');
}

However when I add Foo(42) in my code and try to run it, it doesn't work

Compiler message:
org-dartlang-app:/main.dart:23:16: Error: Method not found: 'Foo'.
        child: Foo(42),
               ^^^
org-dartlang-app:/main.dart:23:16: Error: The method 'Foo' isn't defined for the class 'MyHomePage'.
 - 'MyHomePage' is from 'package:test_functional_widget/main.dart' ('org-dartlang-app:/main.dart').
Try correcting the name to the name of an existing method, or defining a method named 'Foo'.
        child: Foo(42),
               ^^^

flutter build apk log flutter run log flutter doctor

Repository with my example app

rrousselGit commented 4 years ago

You are missing the part 'foo.g.dart'; on the top of your file

PiN73 commented 4 years ago

Thanks, adding part 'foo.g.dart'; solved the problem. I think it's worth adding to readme. Here is a pull request #57