Coder Social home page Coder Social logo

komurapp / simpleformbuilder Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tanmoy27112000/simpleformbuilder

0.0 0.0 0.0 174 KB

A simple form builder for flutter

License: BSD 3-Clause "New" or "Revised" License

Ruby 2.95% Objective-C 0.08% Kotlin 0.27% Dart 95.81% Swift 0.88%

simpleformbuilder's Introduction

Simple Form Builder

pub package GitHub Stars Platform

A complete form builder for all your needs

Maintainer : Tanmoy Karmakar
contributor: Shayon Sarkar

Specs

This library allows you to create a complete form from a json file with multiple types of fields text , checkbox, multiselect , datetime , date , time , and file upload. This package also provides additional remark options.

It has been written 100% in Dart. ❤️

Example Example App Closed Example App Open


Installing

Add the following to your pubspec.yaml file:

dependencies:
  simple_form_builder: ^0.0.18


Simple Usage

To integrate the Simple form builder all you need to do is follow the given JSON schema and pass it to the formBuilder widget

JSON Schema

// The complete sample is provided in the global folder that can be used as a reference

{
  "status": 1,
  "data": [
    {
      "questions": [
        {
          "question_id": String,
          "fields": ["abvoe 40km/h", "below 40km/h", "0km/h"],
          "_id": "60dc6a3dc9fe14577c30d271",
          "title": "Please provide the speed of vehicle?",
          "description": "please select one option given below",
          "remark": true,
          "type": "multiple",
          "is_mandatory": true
        }
      ]
    }
  ]
}

Widget Implementation

import 'package:flutter/material.dart';
import 'package:simple_form_builder/formbuilder.dart';
import 'package:simple_form_builder/global/constant.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'FormBuilder Example',
      home: Scaffold(
        appBar: AppBar(
          title: Text('Material App Bar'),
        ),
        body: SingleChildScrollView(
          child: Column(
            children: [
              FormBuilder(
                initialData: sampleData,
                index: 0,
                showIndex:true,
                // showPrefix
                //radioIcon
                //checklistIcon
                onSubmit: (val) {
                  print(val);
                },
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Custom Usage

There are several options that allow for more control:

Properties Description
initialData This is the map that is required to generate the form. the sample JSON format is given in the constant.dart file
index If the data contains mutiple forms passing the index of the form will show the question of that perticular form
onSubmit This function will take in the map value and pass it to the given function when submit button is pressed
showPrefix This toggle will enable or disable prefix icon before the question
onUpload This contains the file uploaded by user in String
showIndex to specify weather to show numbering or not

simpleformbuilder's People

Contributors

tanmoy27112000 avatar

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.