This is a CLI tool to generate Flutter files including Model, screen, widget... for your Flutter project. It's buit using https://github.com/infinitered/gluegun inspired by https://github.com/infinitered/ignite
-
Clone this repository
-
Open terminal and run this command to active the CLI
yarn link
-
Copy the folder
FG/templatesto your Flutter project root
- Run the bellow commands to generate Models, Screens, or List item.
- The default template files are used for Flutter GetX project, you can modify these files to match with your project templates
To generate a model AbcXyz in the folder lib/models/abc_xyz:
fg-cli generate model AbcXyzTo generate a screen AbcXyz in the folder lib/screens/abc_xyz:
fg-cli generate screen AbcXyzTo generate a list item AbcXyz in the folder lib/list_items/abc_xyz:
fg-cli generate list_item AbcXyzFeel free to modify the templates files in the folder FG/templates.
Your generators live in your app, in FG/templates/*. To make a new generator, go look at the ones that are there when you start your app. You'll see that they have *.ejs files (which get interpreted when you generate them).
fg-cli g screen SettingsThis will copy over any files in FG/templates/screen/* to lib/screens/settings/* and process any .ejs templates at the same time.
Props are passed into the ejs templates when you run the generator.
{
camelCaseName: string // AbcXyz => abcXyz
kebabCaseName: string // AbcXyz => abc_xyz
pascalCaseName: string // AbcXyz => AbcXyz
filename: string // AbcXyz => abc_xyz.dart
}
You can use them in a template with <%= props.camelCaseName %>.
Check out the documentation at https://github.com/infinitered/gluegun/tree/master/docs.
To package your CLI up for NPM, do this:
$ npm login
$ npm whoami
$ npm lint
$ npm test
(if typescript, run `npm run build` here)
$ npm publishMIT - see LICENSE