scaff 1.0.4

Introduction #

Scaffold Generator for Dart and Flutter. #

scaff is a simple command-line utility for generating Dart and Flutter components from template files. It is a very tedious job to keep replicating the boilerplate codes every time you try to add a new component in your app. Using scaff, you can generate dart or flutter components from the custom-defined templates. You can even include template variables in the component files and directories name for easy and flexible scaffolding.

scaff uses 'Mustache templating library' variable schemes for defining and processing the template files.

Installation #

$ pub global activate scaff

Usage #

$ pub global run scaff

Example #

Let us create a simple component. First of all, we need to create a working directory and it should contain a scaff.setup.json file. The scaff.setup.json file should contain all the template variables used in the working directory. The component subdirectories and files should be included inside the working directory.

All template files should have a .tpl extension and scaff will convert them into .dart files. The files and directories name may contain template variables as well.

Template variable examples: {{var1}}, {{className}}Base, {{fileName}}_store

The example template directory structure:

│   └── general_store_architecture
│       ├── scaff.setup.json
│       └── {{componentName}}
│           ├── {{componentName}}.tpl
│           └── {{componentName}}_store.tpl
  1. Create a new directory in the project root
$ mkdir -p component_templates/general_store_architecture
$ cd component_templates/general_store_architecture
  1. Create the component directory
$ mkdir {{componentName}}
$ cd {{componentName}}
  1. Create the component template file
$ touch {{componentName}}.tpl
  1. Add the code to {{componentName}}.tpl file
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../data/mobx/{{componentName}}_store.dart';

class {{className}}Screen extends StatelessWidget {
    Key key,
  }) : super(key: key);

  Widget build(BuildContext context) {
    final {{componentName}} = Provider.of<{{className}}Store>(context);

    return Scaffold(
      body: Center(
        child: Column(),
  1. Create the store template file
$ touch {{componentName}}_store.tpl
  1. Add the code to {{componentName}}_store.tpl file
import 'package:mobx/mobx.dart';

abstract class {{className}}StoreBase with Store {
  bool dummyValue = false;
  1. Create the scaff.setup.json file
$ cd ..
$ touch scaff.setup.json
  1. Add all the template variables used in the working directory to scaff.setup.json file as
  "variables": ["componentName", "className"]
  1. cd into general_store_architecture folder.
$ pwd # it should be pointing to =>  /path/component_templates/general_store_architecture
  1. Run scaff globally
$ pub global run scaff
  1. You will be prompted to:
- Enter source directory (/path/component_templates/general_store_architecture) »
- Enter destination directory (/path/component_templates/general_store_architecture/__component__) »
- Enter 'componentName' variable value » login
- Enter 'className' variable value » Login
  1. The destination directory will have the newly generated component. The destination directory structure:
└── login
    ├── login.dart
    └── login_store.dart

Buy me a coffee #

Help me keep the app FREE and open for all. Paypal me:

Contacts #

Please feel free to contact me at

About #

License #

scaff | Scaffold Generator for Dart and Flutter. MIT License.

Copyright © 2018-Present Ganesh Rathinavel

1.0.4 #

  • Bug fixes
  • Optimizations

1.0.1 #

  • Fixed the global executable path

1.0.0 #

  • Initial version


/// See the repo for usage details.
/// Find the example component_templates directory in this folder

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  scaff: ^1.0.4

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:scaff/scaff.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 15, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5

Health issues and suggestions

Document public APIs. (-1 points)

2 out of 2 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
meta ^1.1.8 1.1.8
mustache ^1.1.1 1.1.1
path ^1.6.0 1.6.4
prompts ^1.3.1 1.3.1
Transitive dependencies
charcode 1.1.3
collection 1.14.12
io 0.3.3
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
Dev dependencies
pedantic ^1.8.0
test ^1.6.0