json_schema_form 0.7.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 80

Flutter JSON Form #

Build Status

This is the plugin for flutter using JSON Schema to define the form itself. It supports:

  • Textfield
  • Selection field
  • forignkey field
  • qrcode scanning
  • custom field icon and action

Getting start #

Important! The forign key field is using Django Rest Framework with DRF-schema-adapter. All the schema's structures are based on it. You can take a look what the structure is on this page

First prepare data #

Map<String, dynamic> itemJSONData = {
  "fields": [
      "label": "ID",
      "readonly": true,
      "extra": {},
      "name": "id",
      "widget": "number",
      "required": false,
      "translated": false,
      "validations": {}
      "label": "Item Name",
      "readonly": false,
      "extra": {"help": "Please Enter your item name", "default": ""},
      "name": "name",
      "widget": "text",
      "required": true,
      "translated": false,
      "validations": {
        "length": {"maximum": 1024}

put the data into JSONSchemaForm #

                schema: (snapshot.data['fields'] as List)
                    .map((s) => s as Map<String, dynamic>)
                icons: [
                  FieldIcon(schemaName: "name", iconData: Icons.title),
                actions: [
                      schemaName: "qr_code",
                      actionTypes: ActionTypes.qrScan,
                      actionDone: ActionDone.getInput)
                onSubmit: (value) {

As you can see, you can provide actions and icons based on the name property in the schema's data.

[0.5.1] - TODO: Add release date.

  • added tests
  • added basic supports for fields


  • added theme data


  • fixed bugs
  • add tests


  • fixed lost text problem


  • Added more tests
  • Added URL param


  • Added more tests


  • Fixed QR scanning issues


  • Added on action done callback
  • Added actions for forign key
  • Added get image action


import 'dart:io';

import 'package:flutter/material.dart';
import 'package:json_schema_form/JSONSchemaForm.dart';
import 'package:json_schema_form/models/Action.dart';
import 'package:json_schema_form/models/Icon.dart';

import 'data/sample_data.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),

class MyHomePage extends StatefulWidget {
  _MyHomePageState createState() => _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {
  Future<Map<String, dynamic>> getSchema() async {
    await Future.delayed(Duration(milliseconds: 100));
    return itemJSONData;

  ThemeData buildTheme() {
    final ThemeData base = ThemeData();
    return base.copyWith(
      iconTheme: IconThemeData(color: Colors.white),
      inputDecorationTheme: InputDecorationTheme(
        fillColor: Colors.blue,
        border: OutlineInputBorder(
          borderSide: BorderSide(color: Colors.green),

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text("Form"),
      body: FutureBuilder<Map<String, dynamic>>(
          future: getSchema(),
          builder: (context, snapshot) {
            if (!snapshot.hasData) {
              return Container();
            return Theme(
              data: buildTheme(),
              child: JSONSchemaForm(
                rounded: true,
                schema: (snapshot.data['fields'] as List)
                    .map((s) => s as Map<String, dynamic>)
                icons: [
                  FieldIcon(schemaName: "name", iconData: Icons.title),
                      schemaName: "description", iconData: Icons.description),
                  FieldIcon(schemaName: "price", iconData: Icons.attach_money),
                  FieldIcon(schemaName: "column", iconData: Icons.view_column),
                  FieldIcon(schemaName: "row", iconData: Icons.view_list),
                  FieldIcon(schemaName: "qr_code", iconData: Icons.scanner),
                  FieldIcon(schemaName: "unit", iconData: Icons.g_translate)
                actions: [
                      schemaName: "qr_code",
                      actionTypes: ActionTypes.image,
                      actionDone: ActionDone.getImage,
                      onDone: (File file) async {
                        if (file is File) {
                        return file;
                      schemaName: "name",
                      schemaFor: "category_id",
                      actionTypes: ActionTypes.image,
                      actionDone: ActionDone.getInput,
                      onDone: (File file) async {
                        if (file is File) {
                        return "abc";
                onSubmit: (value) {
                url: "",
                values: {
                  "author_id": {"label": "sdfsdf", "value": 2},
                  "name": "abc"

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  json_schema_form: ^0.7.3

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:json_schema_form/JSONSchemaForm.dart';
import 'package:json_schema_form/components/JSONForignKeyEditField.dart';
import 'package:json_schema_form/components/JSONForignKeyField.dart';
import 'package:json_schema_form/components/JSONSelectField.dart';
import 'package:json_schema_form/components/JSONTextFormField.dart';
import 'package:json_schema_form/components/SelectionPage.dart';
import 'package:json_schema_form/models/Action.dart';
import 'package:json_schema_form/models/Icon.dart';
import 'package:json_schema_form/models/Schema.dart';
import 'package:json_schema_form/utils.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jan 22, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

Fix lib/components/JSONForignKeyEditField.dart. (-1.49 points)

Analysis of lib/components/JSONForignKeyEditField.dart reported 3 hints:

line 5 col 8: Unused import: 'package:json_schema_form/models/Schema.dart'.

line 27 col 16: The value of the local variable 'response' isn't used.

line 39 col 16: The value of the local variable 'response' isn't used.

Fix lib/components/JSONTextFormField.dart. (-1 points)

Analysis of lib/components/JSONTextFormField.dart reported 2 hints:

line 9 col 8: Unused import: 'package:permission_handler/permission_handler.dart'.

line 36 col 10: This function has a return type of 'String', but doesn't end with a return statement.

Fix lib/models/Action.dart. (-0.50 points)

Analysis of lib/models/Action.dart reported 1 hint:

line 1 col 8: Unused import: 'dart:io'.

Fix lib/models/Schema.dart. (-0.50 points)

Analysis of lib/models/Schema.dart reported 1 hint:

line 1 col 8: Unused import: 'package:flutter/material.dart'.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (permission_handler).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
barcode_scan ^1.0.0 1.0.0
dio ^3.0.1 3.0.8
flutter 0.0.0
image_picker ^0.6.2+3 0.6.3+1
permission_handler ^3.2.2 3.3.0 4.2.0+hotfix.2
progress_indicators ^0.1.4 0.1.4
Transitive dependencies
charcode 1.1.2
collection 1.14.11 1.14.12
flutter_plugin_android_lifecycle 1.0.5
http_parser 3.1.3
meta 1.1.8
path 1.6.4
sky_engine 0.0.99
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
mockito ^4.1.1