This is a command-line app written on dart language for flutter applications that will help you to generate some boilerplate code

Overview

dart-generator

Manual installation:

1- generate a platform executable from code

dart compile exe main.dart -o generator

this will generate a new generator file inside the lib folder.

2- create alias inside your .bash_profile and .zshrc files

alias generator="/Users/userName/packages/generator/lib/generator"

now you can use command line directly from your terminal

Usage:

1- generate factory

generator make factory --name UserFactory

this will generate user_factory.dart file inside data/factories directory

import 'package:famcare/auth/models/user.dart';
import 'package:famcare/auth/models/address.dart';
import 'package:famcare/auth/models/note.dart';

import 'address_factory.dart';
import 'note_factory.dart';

import 'package:faker/faker.dart';

class UserFactory {
  int? id;

  String? name;

  int? age;

  Address? address;

  List<Note>? notes;

  int? _count;

  dynamic create(
      {int? id, String? name, int? age, Address? address, List<Note>? notes}) {
    final mUser = User(
      id: id ?? this.id ?? faker.randomGenerator.integer(2),
      name: name ?? this.name ?? faker.randomGenerator.string(23),
      age: age ?? this.age ?? faker.randomGenerator.integer(2),
      address: address ?? this.address ?? AddressFactory().make(),
      notes: notes ?? this.notes ?? NoteFactory().count(10).make(),
    );
    if (_count != null) {
      return List<User>.filled(_count!, mUser);
    } else {
      return mUser;
    }
  }

  UserFactory state(
      {int? id, String? name, int? age, Address? address, List<Note>? notes}) {
    this.id = id ?? this.id;
    this.name = name ?? this.name;
    this.age = age ?? this.age;
    this.address = address ?? this.address;
    this.notes = notes ?? this.notes;
    return this;
  }

  UserFactory count(int count) {
    _count = count;
    return this;
  }

  UserFactory hasAddress(
      {Address? address,
      int? id,
      Country? country,
      String? address,
      String? street}) {
    if (address != null) {
      this.address = address;
    } else {
      this.address = AddressFactory().create(
        id: id,
        country: country,
        address: address,
        street: street,
      );
    }
    return this;
  }

  UserFactory hasNotes(
      {List<Note>? notes, int? count, String? title, String? content}) {
    if (notes != null) {
      this.notes = notes;
    } else {
      assert(count != null);
      this.notes = NoteFactory().count(count).create(
            title: title,
            content: content,
          );
    }
    return this;
  }
}

2- generate feature first you need to create a yaml file with the content of this feature and the file name must have the same feature name

for example for emition traccker feature we create emotions_tracker.yaml inside emotions_tracker feature package

name: emotions_tracker


data:
  base_url: ***.***.app
  headers: { Authorization: Bearer ******,
             Content-Type: application/json }
  apis:
    - name: getEmotions
      method: GET
      path: api/v2/emotions
      model: Emotion
      response_model: ListResponse
    - name: addDailyEmotion
      method: POST
      path: api/v2/users/userId/emotions
      body: {emotion_id: 1, diary: hello im sad}
      values: {userId: 4}
      response_model: SuccessResponse
    - name: getCurrentEmotion
      method: GET
      path: api/v2/users/userId/emotions
      values: { userId: 4 }
      model: UserEmotion
      response_model: SingleResponse
    - name: emotionsHistory
      method: GET
      path: api/v2/users/userId/emotions-history
      values: {userId: 4}
      model: UserEmotion
      response_model: ListResponse
  create_repo: true
  events:
    - name: View Daily Emotion
      params: [Placement]
    - name: View Emotions History
      params: []
    - name: View Specific Day Emotional
      params: [Id, Emotion Id,  Emotion Text,  Created At]

presentations:
  - name: DailyEmotionView
    controllers:
      - initial_api: getCurrentEmotion
        apis: [getCurrentEmotion]
    feature_flag:
      key: emotions_feature_flag
    generate_route: false
  - name: FillDailyEmotionPage
    controllers:
      - initial_api: getEmotions
        apis: [addDailyEmotion]
    generate_route: true
  - name: EmotionsHistoryPage
    controller:
      - initial_api: emotionsHistory
        apis: [emotionsHistory]
    generate_route: true

Then write this command:

generate make feature --name emotionsTracker

This will generate a all data files:

  • Emotion
  • UserEmotion
  • EmotionsTrackerRemoteDataSource
  • EmotionsTrackerRepository
  • ViewDailyEmotionEvent
  • ViewEmotionsHistoryEvent
  • ViewSpecificDayEmotionalEvent
You might also like...

Given a JSON string, this library will generate all the necessary Dart classes to parse and generate JSON.

JSON to Dart Given a JSON string, this library will generate all the necessary Dart classes to parse and generate JSON. This library is designed to ge

Dec 25, 2022

This is a mason brick you can use to generate code that get's you started right up with a flutter project

flutter_brick This is a mason brick you can use to generate code that gets you started right up with a flutter project A flutter brick created with th

Sep 16, 2022

Screenshots - A command line utility and package for capturing screenshots for Flutter

Screenshots - A command line utility and package for capturing screenshots for Flutter

A screenshot image with overlaid status bar placed in a device frame. For an example of images generated with Screenshots on a live app in both stores

Nov 22, 2022

An incredible command line interface for Flutter.

An incredible command line interface for Flutter.

Fast CLI An incredible command line interface for Flutter. It allows you to create your own CLI without coding a line. With this CLI, you can create y

Jul 12, 2022

shared_versions is a command line tool that allow share the versions for multiple packages in Flutter

shared_versions shared_versions is a CLI tool that allow share the versions for multiple packages in Flutter. Usage shared_versions will match the pac

Sep 20, 2022

Listen to remote Flutter GTK application instances' command-line arguments and file open requests.

gtk_application This package allows the primary Flutter GTK application instance to listen to remote application instances' command-line arguments and

Dec 15, 2022

A command-line application provide an load optimization solution for flutter web

A command-line application provide an load optimization solution for flutter web

一个命令行工具,针对flutter web加载慢和缓存问题提供了一套解决方案。 功能 通过大文件分片和资源文件cdn化方式,优化flutter web页面加载慢问题。 通过资源文件hash化,解决浏览器强缓存导致功能无法更新问题。 开始 局部安装 dev_dependencies: flutte

Dec 29, 2022

Command Line Interface (CLI) for Lucifer

Lucy Command Line Interface (CLI) for Lucifer. Installation Activate command line from your terminal with this command. pub global activate lucy Usage

Dec 16, 2021

☄ Anime/Manga command-line interface backed up by Tenka.

☄ Anime/Manga command-line interface backed up by Tenka.

Yukimi ☄ Anime/Manga command-line interface backed up by Tenka. By using this project, you agree to the usage policy. Installation Pre-built binaries

Jan 6, 2023
Owner
One Studio
One Studio
This is a simple Gantt chart generator written as Dart command line tool.

Gantt Chart Generator This is a simple Gantt chart generator written as Dart command line tool. Currently the tool generates an HTML/CSS Gantt chart.

John Lyon-Smith 1 Apr 26, 2022
null 1 Jan 8, 2022
Flutter boilerplate - A boilerplate project created in flutter using MobX and Provider

Boilerplate Project A boilerplate project created in flutter using MobX and Prov

Wali Khan 0 Jan 22, 2022
Package your Flutter app into OS-specific bundles (.dmg, .exe, etc.) via Dart or the command line.

flutter_distributor Package your Flutter app into OS-specific bundles (.dmg, .exe, etc.) via Dart or the command line. The flutter_distributor source

LeanFlutter 416 Dec 24, 2022
Scaff is a simple command-line utility for generating Dart and Flutter components from template files.

Introduction Scaffold Generator for Dart and Flutter. scaff is a simple command-line utility for generating Dart and Flutter components from template

Ganesh Rathinavel Medayil 29 Jul 17, 2022
A Nerolab Command Line Interface for Dart created by Nerolab

Nerolab CLI Nerolab Command Line Interface for Dart. Special thanks to GroovinChip with groovin_cli and very_good_cli. Installing dart pub global acti

Nerolab 1 Jan 19, 2022
changelog.dart provides a library and a command-line application to manage in the correct way the git metadata to build the changelog between two release

changelog.dart ?? changelog.dart: a collection of tools to manages in a fashion way a repository as maintainer. ?? Project Homepage Table of Content I

Vincenzo Palazzo 7 Dec 18, 2022
Interactive command line interface Couchbase Lite REPL utility built with the Dart

Couchbase Lite Dart CLI Interactive command line interface Couchbase Lite REPL utility built with the Dart programming language. This code uses the cb

Pieter Greyling 2 Jul 20, 2022
Tool made in Dart that allows you to dynamically generate JSON files from data models written in Dart.

Dart JSON Generator Versión v1.1.1 Dart JSON Generator es una herramienta que permite generar archivos JSON a partir de mapas como modelos de datos en

Joinner Medina 7 Nov 23, 2022
Icons Launcher - A command-line tool that simplifies the task of updating your Flutter app's launcher icon.

Icons Launcher - A command-line tool that simplifies the task of updating your Flutter app's launcher icon. Full flexibility allows you to only update the launcher icon for specific platforms as needed.

Mrr Hak 48 Nov 17, 2022