Skip to main content

A code generator for Flutter

Project description

Code generator for Flutter apps


Install using pip3:

Open Terminal and run:

$ brew install python
$ pip3 install ptfgen


$ pip3 install -U ptfgen


$ pip3 uninstall ptfgen

1. Create Template:

1.1. Base Template:

The Base Template contains necessary files for a screen using the Flutter Clean Architecture pattern.

Open Terminal, navigate to your flutter project folder you want to save the files and run:

$ ptfgen template base <Scene_Name>


$ ptfgen template base LoginEmail


Successfully created files:

2. Create models from JSON:

Copy the json then run the command:

$ ptfgen json <Model_Name> [-p]


-p, --print: print the result.


Copy the json:

        {"name":"Shyam", "email":""},  
        {"name":"Bob", "email":""},  
        {"name":"Jai", "email":""}  

then run:

$ ptfgen json Company


The result has been copied to the pasteboard.

Content in the pasteboard:

import 'package:pt_object_mapper/pt_object_mapper.dart'; 

/// Remember register to Mappable.factories
/// Mappable.factories[Employee] = () => Employee();

class Employee with Mappable {
  String name;
  String email;

  void mapping(Mapper map) {
    map("name", name, (v) => name = v);
    map("email", email, (v) => email = v);

/// Remember register to Mappable.factories
/// Mappable.factories[Company] = () => Company();

class Company with Mappable {
  List<Employee> employees;

  void mapping(Mapper map) {
    map<Employee>("employees", employees, (v) => employees = v);

3. Create a mock class for a protocol/function:

Copy the abstract/function then run:

$ ptfgen mock [-p]


-p, --print: print the result.


Copy the abstract:

abstract class SignUpEmailUseCaseType {
  Stream<User> signUpWithEmail(String email, String password);
  ValidationResult validateEmail(String email);
  ValidationResult validatePassword(String password);

then run:

$ ptfgen mock


The result has been copied to the pasteboard.

Content in the pasteboard:

class SignUpEmailUseCaseMock implements SignUpEmailUseCaseType {

    /// signUpWithEmail

    var signUpWithEmail_Called = false;
    var signUpWithEmail_ReturnValue = Stream<User>.value(null);

      Stream<User> signUpWithEmail(String email, String password) {
        signUpWithEmail_Called = true;
        return signUpWithEmail_ReturnValue;

    /// validateEmail

    var validateEmail_Called = false;
    var validateEmail_ReturnValue = ValidationResult.valid();

      ValidationResult validateEmail(String email) {
        validateEmail_Called = true;
        return validateEmail_ReturnValue;

    /// validatePassword

    var validatePassword_Called = false;
    var validatePassword_ReturnValue = ValidationResult.valid();

      ValidationResult validatePassword(String password) {
        validatePassword_Called = true;
        return validatePassword_ReturnValue;

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ptfgen, version 1.0.3
Filename, size File type Python version Upload date Hashes
Filename, size ptfgen-1.0.3.tar.gz (15.7 kB) File type Source Python version None Upload date Hashes View
Filename, size ptfgen-1.0.3-py3-none-any.whl (22.6 kB) File type Wheel Python version py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page