formcraft 0.0.1 copy "formcraft: ^0.0.1" to clipboard
formcraft: ^0.0.1 copied to clipboard

FormCraft - Cross-Platform Dynamic Form Builder

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:formcraft/formcraft.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      darkTheme: ThemeData.dark(useMaterial3: true),
      home: const Center(
        child: FormCraft(
            data: {
              "name": "FormCraft",
              "type": "form",
              "build": {
                "component": "column",
                "children": [
                  {
                    "component": "container",
                    "child": {
                      "component": "column",
                      "mainAxisAlignment": "center",
                      "crossAxisAlignment": "center",
                      "children": [
                        {
                          "component": "textField",
                          "key": "FormCraftInput",
                          "initialValue": "Hello World!",
                          "logic": [
                            {
                              "name": "Update Values: Animals",
                              "trigger": {
                                "type": "simple",
                                "simple": {
                                  "show": true,
                                  "when": "age",
                                  "eq": "a"
                                }
                              },
                              "actions": [
                                {
                                  "name": "Schema Update",
                                  "type": "mergeComponentSchema",
                                  "schemaDefinition": "schema = {values:[{label: 'Cat', value: 'cat'}, {label:'Dog', value: 'dog'}]};"
                                }
                              ]
                            },
                            {
                              "name": "Update Values: Fruits",
                              "trigger": {
                                "type": "simple",
                                "simple": {
                                  "show": true,
                                  "when": "age",
                                  "eq": "b"
                                }
                              },
                              "actions": [
                                {
                                  "name": "Update fruit",
                                  "type": "mergeComponentSchema",
                                  "schemaDefinition": "schema = {values:[{label: 'Apple', value: 'apple'}, {label:'Banana', value: 'banana'}]};"
                                }
                              ]
                            }
                          ],
                        },
                        {
                          "component": "groupRadio",
                          "key": "FormCraftRadioGroup",
                          "values": [
                            {
                              "value": "1",
                              "label": "One"
                            },
                            {
                              "value": "2",
                              "label": "Two"
                            },
                            {
                              "value": "3",
                              "label": "Three"
                            }
                          ],
                        },
                        {
                          "component": "checkbox",
                          "key": "FormCraftCheckbox",
                          "label": "Hey! It's warioddly"
                        },
                        {
                          "component": "groupCheckbox",
                          "key": "FormCraftCheckboxGroup",
                          "values": [
                            {
                              "value": "1",
                              "label": "One"
                            },
                            {
                              "value": "2",
                              "label": "Two"
                            },
                            {
                              "value": "3",
                              "label": "Three"
                            }
                          ]
                        },
                        {
                          "component": "textField",
                          "key": "FormCraftInput765",
                          "initialValue": "Hello 124124124124124!",
                        },
                        {
                          "component": "text",
                          "data": "Hey! It's warioddly",
                        }
                      ]
                    },
                  }
                ]
              }
            }
        ),
      ),
    );
  }


}
1
likes
110
pub points
0%
popularity

Publisher

unverified uploader

FormCraft - Cross-Platform Dynamic Form Builder

Homepage

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

collection, expandable_page_view, flutter, flutter_form_bloc, flutter_web_plugins, form_bloc, plugin_platform_interface, provider

More

Packages that depend on formcraft