Git Product home page Git Product logo

sudhi001 / formstack Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 2.02 MB

FormStack is a library designed to help developers create dynamic user interfaces in Flutter. Specifically, the library is focused on creating forms and surveys using a JSON or Dart language model.

License: MIT License

Java 0.79% Shell 0.50% Objective-C 0.83% Dart 75.48% C++ 10.14% C 0.87% CMake 8.66% Swift 0.74% Kotlin 0.05% HTML 0.79% Ruby 1.15%

formstack's Introduction

logo

FormStack

Comprehensive Library for Creating Dynamic Form

Platform License: MIT FormStack Library version License: MIT

FormStack is a library designed to help developers create dynamic user interfaces in Flutter. Specifically, the library is focused on creating forms and surveys using a JSON or Dart language model.

The primary goal of FormStack is to make it easy for developers to create dynamic UIs without having to write a lot of code. By using a JSON or Dart model to define the structure of a form or survey, developers can quickly create UIs that are easy to customize and update.

While the library was initially created to help developers create survey UIs, the focus has expanded to include any type of dynamic application UI. With FormStack, developers can create UIs that are responsive and adaptable to different devices and screen sizes.

Overall, FormStack is a powerful tool for creating dynamic user interfaces in Flutter. It offers a flexible and customizable approach to UI design, allowing developers to create UIs that are easy to use and maintain.

Supported Components

  • ✅ TextFiled - Text
  • ✅ TextFiled - Number
  • ✅ TextFiled - Password
  • ✅ TextFiled - Name
  • ✅ TextFiled - Email
  • ✅ TextFiled - File Picker
  • ✅ TextFiled - OTP View
  • ✅ Cupertino Picker View - Date Only
  • ✅ Cupertino Picker View - Date Time
  • ✅ Cupertino Picker View - Time Only
  • ✅ Single Selection List
  • ✅ Mutiple Selection List
  • ✅ Dropdown List
  • ✅ Smile Rating
  • ✅ Dynamic Key Value Widget
  • ✅ HTML Editor
  • ✅ Location Picker (Using Google Map and Google Place Auto completer API)

Online Demo

Dart Versions

  • Dart >=2.19.6 < 3.0.0

Examples

Implementation

Follwoing JSON medel will render the above demo screen ui.

{
    "default":
    {
      "backgroundAnimationFile":"assets/bg.json",
      "backgroundAlignment":"bottomCenter",
      "steps":[
        {
          "type": "QuestionStep",
          "title":"My Car",
          "cancellable":false,
          "titleIconAnimationFile":"assets/car.json",
          "nextButtonText":"",
          "autoTrigger":true,
          "inputType":"singleChoice",
          "options":[
             {"key":"CAR_SELECTED","title":"Select A Car"},
             {"key":"CALL_DRIVER","title":"Call Driver Now"}
          ],
          "id":"CHOICE",
          "relevantConditions":[{"id":"CALL_DRIVER","expression":"IN CALL_DRIVER"}]
        },{
          "type": "QuestionStep",
          "title":"Select Car",
          "titleIconAnimationFile":"assets/car.json",
          "nextButtonText":"",
          "autoTrigger":true,
          "inputType":"singleChoice",
          "options":[
             {"key":"AUDI","title":"Audi"},
             {"key":"BENZ","title":"Benz"},
             {"key":"Suzuki","title":"Suzuki"}
          ],
          "id":"CAR_SELECTED",
          "relevantConditions":[{"id":"SMILE","expression":"FOR_ALL"}]
        },{
          "type": "QuestionStep",
          "title":"Call / Ping Driver",
          "titleIconAnimationFile":"assets/car.json",
          "nextButtonText":"",
          "autoTrigger":true,
          "inputType":"singleChoice",
          "options":[
             {"key":"CALL","title":"Call"},
             {"key":"PING","title":"PING"}
          ],
          "id":"CALL_DRIVER"
        },
        {
         "type": "QuestionStep",
         "title":"Are you Happy",
         "text":"",
         "inputType":"smile",
         "id":"SMILE"
       },
        {
          "type": "CompletionStep",
          "autoTrigger":true,
          "nextButtonText":"",
          "title":"Please wait..",
          "id":"IS_COMPLETED"
        }
      ]
    
   }
}

Load single json file from assets folder

     await FormStack.api() .loadFromAsset('assets/app.json');

Load Mutiple json file from assets folder

     await FormStack.api()
                      .loadFromAssets(['assets/app.json', 'assets/full.json']);

Read json file from assets to FormStack

await FormStack.api().buildFormFromJson(
        await json.decode(await rootBundle.loadString('assets/app.json')));

Completion Call back

Here you can implement your logic. Example: if you want to trigger a network call or something like that.

    FormStack.api().addCompletionCallback(
      GenericIdentifier(id: "IS_COMPLETED"),
      onBeforeFinishCallback: (result) async {
        await Future.delayed(const Duration(seconds: 2));/// Replace this line and add your network logic
        return Future.value(true);
      },
      onFinish: (result) {
        debugPrint("Completed With Result : $result");
        FormConfig.setState?.call();
      },
    );

Render Form in UI

 FormStack.api().render()

Set Error dynamicaly

         FormStack.api().setError(
                            GenericIdentifier(id: "email"), "Invalid email,",
                            formName: "login_form");

Set Data dynamicaly

          FormStack.api().setResult({"email": "[email protected]"},
                        formName: "login_form");

Disable UI dynamically

          FormStack setDisabledUI(["email"], formName: "login_form") 

FormStack setDisabledUI(List disabledUIIds, {String? formName = "default"})

Demo Application Video

FormStack Demo Application Video

New Components

File Uploader Dynamic Component OTP
HTML Editor Location Pickerr

Modify the tag of your web/index.html to load the Google Maps JavaScript API, like so:

<head>

  <!-- // Other stuff -->

  <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY"></script>
</head> 

Screenshots

img1 img2
img3 img4
img5 img6
img7 img8
img10 img11
img9

Bugs or Requests

If you come across any difficulties, don't hesitate to open an issue on GitHub. If you believe that the library lacks a particular feature, please create a ticket on GitHub, and I'll investigate it. Additionally, I welcome pull requests if you would like to contribute to the project.

Maintainers

formstack's People

Contributors

sudhi001 avatar

Watchers

 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.