rrousselGit / functional_widget

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

buiding incorrect class with @widget annotation #53

Closed pishguy closed 5 years ago

pishguy commented 5 years ago

i think this code:

@widget
Widget _loader(BuildContext context, String message) {
  return Center(
      child: Column(
    mainAxisAlignment: MainAxisAlignment.center,
    crossAxisAlignment: CrossAxisAlignment.center,
    children: <Widget>[
      ColorLoader3(
        radius: 25.0,
        dotRadius: 5.0,
      ),
      Padding(
        padding: const EdgeInsets.all(3.0),
        child: Text(
          Strings.pleaseWait,
          style: AppTheme(context).caption().copyWith(color: Colors.red[900]),
        ),
      ),
    ],
  ));
}

should be build this class:

class _Loader extends StatelessWidget {
  const _Loader(this.message, {Key key}) : super(key: key);

  final String message;

  @override
  Widget build(BuildContext _context) => Center(
          child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          ColorLoader3(
            radius: 25.0,
            dotRadius: 5.0,
          ),
          Padding(
            padding: const EdgeInsets.all(3.0),
            child: Text(
              Strings.pleaseWait,
              style: AppTheme(_context).caption().copyWith(color: Colors.red[900]),
            ),
          ),
        ],
      ));
}

but i have:

class _Loader extends StatelessWidget {
  const _Loader(this.message, {Key key}) : super(key: key);

  final String message;

  @override
  Widget build(BuildContext _context) => _loader(_context, message);
}
rrousselGit commented 5 years ago

Why is that wrong? The behavior is strictly the same

pishguy commented 5 years ago

@rrousselGit because of in the library sample code i see another implemented code on .g.dart

rrousselGit commented 5 years ago

That example?

The extra code is not the content of the build method, but an implementation of debugFillProperties, hashCode, and ==

pishguy commented 5 years ago

@rrousselGit i think yes, maybe i made mistake

rrousselGit commented 5 years ago

No problem 😄

I'll close the issue for now. Feel free to reopen it if you feel that there's truly an issue

pishguy commented 5 years ago

@rrousselGit i don't know why build command in terminal don't make .g.dart class ???

i try on 1 hour to make it. i don't get any error

[INFO] Succeeded after 889ms with 0 outputs (0 actions)