flutter_gen_cli 1.0.0 copy "flutter_gen_cli: ^1.0.0" to clipboard
flutter_gen_cli: ^1.0.0 copied to clipboard

A package CLI to generate components, pages, services and other files in Flutter projects in a fast and consistent way.

Flutter Gen CLI #

Pub Version License: MIT

A package CLI to generate components, pages, services and other files in Flutter projects in a fast and consistent way.


📦 Installation #

Add the package to your Flutter project:

dart pub global activate flutter_gen_cli

📝 Usage #

Setup #

Create a flutter_gen_config.yaml file in the root of your project with the following content:

generators:
  component:
    description: "Generate a component"
    prompts:
      - type: input
        name: name
        message: "What's the name of the component?"
      - type: input
        name: path
        message: "What's the path of the component?"
    actions:
      - type: add
        path: "lib/components/{{snackCase path}}/{{snakeCase name}}.dart"
        template: "templates/component.dart.hbs"

Generate #

Run the following command in your project's root directory:

dart run flutter_gen_cli generate --generator component

The generator will ask you for the name of the component, the path of the component and the template of the component. It will then generate the component in the specified path with the specified template.

OBS: Responses must always be given in the snack_case pattern, for the helpers to work correctly

📝 Helpers #

Helper Description
{{pascalCase name}} Converts the name to PascalCase
{{camelCase name}} Converts the name to camelCase
{{snakeCase name}} Converts the name to snake_case

📝 Templates #

You can use the following templates:

import 'package:flutter/material.dart';

class {{pascalCase name}} extends StatelessWidget {
  const {{pascalCase name}}({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.blue,
      child: Center(
        child: Text(
          '{{title}}',
          style: TextStyle(color: Colors.white),
        ),
      ),
    );
  }
}

The result will be:

import 'package:flutter/material.dart';

class MyComponent extends StatelessWidget {
  const MyComponent({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.blue,
      child: Center(
        child: Text(
          'my_component',
          style: TextStyle(color: Colors.white),
        ),
      ),
    );
  }
}
## 📝 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
1
likes
130
points
22
downloads

Publisher

unverified uploader

Weekly Downloads

A package CLI to generate components, pages, services and other files in Flutter projects in a fast and consistent way.

Documentation

API reference

License

MIT (license)

Dependencies

args, mustache_template, path, yaml

More

Packages that depend on flutter_gen_cli