rrousselGit / functional_widget

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

Build command doesn't make .g.dart class #54

Closed pishguy closed 5 years ago

pishguy commented 5 years ago

this is my simple class which i want to use @fn.widget in that, but after 3 hours that i try to make class for building widget as class i can't.

i don't get any error

...
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:functional_widget_annotation/functional_widget_annotation.dart' as fn;
...

part 'activity_show_post_content.g.dart';

class ActivityShowPostContent extends StatefulWidget {
  final int postId;

  ActivityShowPostContent({@required this.postId});

  @override
  _ActivityShowPostContentState createState() => _ActivityShowPostContentState();
}

class _ActivityShowPostContentState extends State<ActivityShowPostContent> {
  int get _postId => widget.postId;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Container(
          child: FutureBuilder(
            future: Provider.of<DiabetistApiService>(context).getSinglePost(_postId),
            builder: (context,snapshot){
              if (snapshot.connectionState == ConnectionState.done) {
                if (snapshot.hasData) {
                  return Text(snapshot.data);
                } else {
                  return _loader(context,"List is empty");
                }
              }

              return _loader(context,Strings.pleaseWait);
            },
          ),
        ));
  }

  @fn.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(
                message,
                style: AppTheme(context).caption(),
              ),
            ),
          ],
        ));
  }
}

and this is build output in console:

E:\Projects\Flutter\project>flutter packages pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 1.3s

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 1.0s

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 3.7s

[INFO] Running build...
[INFO] 1.1s elapsed, 0/12 actions completed.
[INFO] 2.3s elapsed, 0/12 actions completed.
[INFO] 3.5s elapsed, 0/12 actions completed.
[INFO] 4.6s elapsed, 0/12 actions completed.
[INFO] 5.9s elapsed, 0/12 actions completed.
[INFO] 7.2s elapsed, 0/12 actions completed.
[INFO] 8.5s elapsed, 0/12 actions completed.
[INFO] 9.6s elapsed, 0/12 actions completed.
[INFO] 10.8s elapsed, 0/12 actions completed.
[INFO] 25.7s elapsed, 1/12 actions completed.
[INFO] 27.1s elapsed, 1/12 actions completed.
[INFO] 30.1s elapsed, 2/12 actions completed.
[INFO] 31.2s elapsed, 11/12 actions completed.
[INFO] 32.7s elapsed, 12/12 actions completed.
[INFO] 33.7s elapsed, 24/24 actions completed.
[INFO] 34.8s elapsed, 36/36 actions completed.
[INFO] 36.0s elapsed, 48/48 actions completed.
[INFO] 37.1s elapsed, 60/60 actions completed.
[INFO] 38.2s elapsed, 69/75 actions completed.
[INFO] Running build completed, took 38.4s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 638ms

[INFO] Succeeded after 39.0s with 0 outputs (75 actions)

--------------------------------------------------------------------------

E:\Projects\Flutter\project>flutter packages pub run build_runner build
[INFO] Generating build script...
[INFO] Generating build script completed, took 1.2s

[INFO] Initializing inputs
[INFO] Reading cached asset graph...
[INFO] Reading cached asset graph completed, took 1.1s

[INFO] Checking for updates since last build...
[INFO] Checking for updates since last build completed, took 2.9s

[INFO] Running build...
[INFO] Running build completed, took 303ms

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 565ms

[INFO] Succeeded after 915ms with 0 outputs (0 actions)
rrousselGit commented 5 years ago

I'll investigate and see why there's no log in the console.

In the mean time, consider the other solution (@swidget), it'll likely work

pishguy commented 5 years ago

@rrousselGit

also swidget, it doesn't work :(

[INFO] Succeeded after 36.7s with 0 outputs (42 actions)

and i tested --delete-conflicting-outputs too

rrousselGit commented 5 years ago

Oh wait, you used it as a method of _ActivityShowPostContentState. That's not good, it must be a top level function.

pishguy commented 5 years ago

@rrousselGit you right, fixed, i'm so sorry