rrousselGit / functional_widget

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

Fix annotations with parameters #98

Closed Almighty-Alpaca closed 2 years ago

Almighty-Alpaca commented 2 years ago

I'm using this library together with auto_route which expects an annotation on e.g. query parameters:

@FunctionalWidget()
Widget myPage(
  BuildContext context, {
  @QueryParam('tab') int? initialTabIndex,
}) => Container();

Previously, the constructor for the generated widget was missing the brackets and therefore also parameters:

const MyPage({Key? key, @QueryParam this.initialTabIndex})

This PR fixed that behavior and copies the whole annotation source from the function widget to the constructor:

const MyPage({Key? key, @QueryParam('tab') this.initialTabIndex})

I've also added some tests for this case.