Skip to content

Instantly share code, notes, and snippets.

@frencojobs
Last active June 1, 2020 03:26
Show Gist options
  • Save frencojobs/2f2f302e764f6afb3a326be2d4034b9e to your computer and use it in GitHub Desktop.
Save frencojobs/2f2f302e764f6afb3a326be2d4034b9e to your computer and use it in GitHub Desktop.
SourceCode generation helper for Flutter.
# pip install click
import click
import os
@click.command()
@click.option('--watch', is_flag=True, help='Watch file changes during build.')
@click.option('--restart', is_flag=True, help='Delete conflicting outputs.')
def generate(**kwargs):
'''Run build_runner source code generation'''
watch = kwargs['watch']
restart = kwargs['restart']
command = 'flutter packages pub run build_runner {buildType} {withRestart}'
buildType = 'watch' if watch else 'build'
withRestart = '--delete-conflicting-outputs' if restart else ''
executable = command.format(buildType=buildType, withRestart=withRestart)
os.system(executable)
if __name__ == '__main__':
generate()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment