Giter VIP home page Giter VIP logo

formbloc_vs_code's Introduction

formbloc ๐Ÿ“

A VSCode extension to generate Blocs that handle forms. Say goodbye to all the boilerplate event factories and event handlers ร  la void _onSth(Event event, Emitter emit) => emit(state.copyWith(sth: event.sth));, just generate it!

Features ๐Ÿš€

Generates boilerplate bloc code to be used as state management of some fill-out-form within your flutter app!

Usage ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป

When run, it will prompt you for

  • the name of the bloc (as the regular bloc VSCode extension does)
  • the number of attributes (if your bloc manages name, email and password, you would type in "3" here)

Then for each attribute:

  • its name (the name of the attribute in the code)
  • its stateType (the type it holds within the bloc state)
  • its submissionType (the type it holds when you send it to the backend)

And last but not least

  • generate submission params (yes, no)

This is part of the clean code architecture I established, if you do not know what this is, feel free to check it out or just respond "No" to this prompt.

Why stateType and submissionType?

Say you want to receive a user input to set a value of your MyEnum enum. If you use the type MyEnum in the bloc's state, you will have to pass it some value when instantiating the blocstate, thus you will need to define an initial value, or define which one of the values you want to have there initially. If on the other hand you used MyEnum? (i.e. made it nullable) within the bloc's state, you can circumvent this intial value problem. So here, you would pass MyEnum? as stateType and MyEnum as submissionType. On the other hand, if you DO want an initial value (say for instance MyEnum.dessert), then you can of course just pass MyEnum as stateType, as well as submissionType.

Requirements โ„น๏ธ

This is not a strong requirement per se, as the extension will always work, but it will generate code that uses syntax of the flutter package freezed. Thus, if you do not use freezed in your flutter app, you might be having a hard time finding this extension useful.

Roadmap ๐Ÿ›ฃ

Additional templates with syntax that supports users of Equatable or nothing (i.e. a default mode, that will always compile) will maybe be added in the future.

Extension Settings โš™๏ธ

This extension contributes the following settings:

  • formbloc.newFormBlocTemplate.createDirectory: Whether to create a directory called "bloc" and create the new form bloc inside of it.

Enjoy!

formbloc_vs_code's People

Contributors

julienandco avatar

Watchers

 avatar

formbloc_vs_code's Issues

Generation Problems

  • The name of the state if FooStateEditing, should be FooEditing
  • In the event class, the semicolon is missing after every event, except for submit

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.