'Is there a way to apply Flutter build_runner to dependencies?

I have a Flutter app project app and a dependency project lib that contains generated code by json_serializable, built_value, etc..
app builds successfully when lib has generated code like source.g.dart.
But when source.g.dart does not exists, app build failed and I have to rerun build_runner on lib.
And I'm going to host lib on GitLab and don't want to track *.g.dart on git.
So, every time I clone or pull code that needs code generation from GitLab, I must remember to run build_runner on lib or get error:source.g.dart does not exists.
Off course I can write script like below.

  1. run build_runner on lib
  2. build app

But I believe there is a better way to tell the build system from lib,
Hey, I want to run build_runner on me.

Is this possible ?
If so, please let me know.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source