schema_form 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 63

GitHub issues GitHub forks GitHub stars GitHub license Pub style: effective dart GitHub tag (latest SemVer) GitHub top language GitHub contributors GitHub last commit

Convert Json Schema to Form for Flutter apps #

What is it #

Schema_form is a Flutter package based on two other packages that produces forms dynamically interpreting JSON objects:

  • dynamic_widget - Which builds forms through JSON interpretation;
  • json_schema - Identifying, defining and validating the properties of the object being edited.

Motivation #

A major difficulty for any application developer is to ensure that all users keep their applications up to date to ensure the same user experience and to reduce the time required to fix bugs.

The most commonly used alternative to accelerate this process is Code Push which allows the application update without the need for a new deploy in the store. However in Code Push GitHub itself there is a Code Push Support for Flutter request with comment saying that support depends on implementing dynamic update support in Flutter, there is also a reference to Flutter Roadmap saying that support for This type of update is postponed according to the official comment Code Push / Hot Update / out of band updates, which explains the reasons that led to the decision.

One possible solution to this deadlock is to implement a JSON interpreter that enables screen redesign, which can be obtained using dynamic_widget. However dynamic_widget does not support a dynamic form. This package was designed to meet this need.

How this work #

Getting Started #

  • For help over FormSchema usage, view the example;
  • For help over class documentation, view the documentation;
  • For help getting started with Flutter, view our online documentation;
  • For help on editing package code, view the documentation.

Installation #

  • Add this to your package's pubspec.yaml file:
dependencies:
  schema_form: "^1.0.0"
  • You can install packages from the command line: with Flutter:
$ flutter packages get
  • Import it Now in your Dart code, you can use:
 import 'package:schema_form/schema_form.dart'; 

Usage #

  JsonSchemaBloc jsonSchemaBloc = JsonSchemaBloc(formContext: context); // Business Logic
  SchemaForm schemaForm = SchemaForm(jsonSchemaBloc: jsonSchemaBloc);   // Form Widget

  // Load files
  File layoutSchemaFile = new File("layoutSchema.json");  // JSON screen layout
  File dataSchemaFile = new File("dataSchema.json");      // Data Schema
  File dataValueFile = new File("dataValue.json");        // Object for editing

  // Get content of files
  String layoutSchemaContent = layoutSchemaFile.readAsStringSync();
  String dataSchemaContent = dataSchemaFile.readAsStringSync();
  String dataValueContent = dataValueFile.readAsStringSync();

  // Turn content into Map
  Map<String, dynamic> layoutSchemaMap = json.decode(layoutSchemaContent);
  Map<String, dynamic> dataSchemaMap = json.decode(dataSchemaContent);
  Map<String, dynamic> dataValueMap = json.decode(dataValueContent);

  // Turn Map into JsonSchema
  JsonSchema dataJsonSchema = JsonSchema.createSchema(dataSchemaMap);

  // Load to Business Logic
  jsonSchemaBloc.add(LoadLayoutSchemaEvent(layout: layoutSchemaMap));   // Layout
  jsonSchemaBloc.add(LoadDataSchemaEvent(dataSchema: dataJsonSchema));  // Json Schema
  jsonSchemaBloc.add(LoadDataEvent(data: dataValueMap));                // Object in edit

  print(jsonSchemaBloc.getFormData());  // Print the object being edited

Next steps #

  • [x] Make MVP
  • [x] Minimal documentation
  • [ ] Change event binding of click event

[0.0.1] - 2019-09-23 #

  • Basic convert Json Schema to Form.

[0.0.2] - 2019-11-02 #

  • Version corrections to publish.

[0.0.3] - 2019-11-04 #

  • Added new dependencies and upgrade package dependencies to publish.

[0.1.0] - 2019-11-04 #

  • Remoting warnings;
  • Release;

[0.1.1] 2019-11-05 #

  • Update to Bloc 2.0.0.

[0.1.2] 2019-11-20 #

  • Update package dependencies.

[1.0.0] 2019-11-29 #

  • Update package dependencies;
  • Add class documentation;
  • Better documentation.

example/README.md

generate_form #

A new Flutter project.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

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


dependencies:
  schema_form: ^1.0.0

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:schema_form/schema_form.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
43
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
60
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/bloc/json_schema_bloc.dart. (-0.50 points)

Analysis of lib/bloc/json_schema_bloc.dart reported 1 hint:

line 112 col 5: 'await' applied to 'Future

Fix lib/common/parser/schema_form_parser.dart. (-0.50 points)

Analysis of lib/common/parser/schema_form_parser.dart reported 1 hint:

line 30 col 11: Close instances of dart.core.Sink.

Fix lib/common/parser/schema_row_radio_list_tile_form_field_parser.dart. (-0.50 points)

Analysis of lib/common/parser/schema_row_radio_list_tile_form_field_parser.dart reported 1 hint:

line 33 col 11: Close instances of dart.core.Sink.

Fix lib/common/parser/schema_switch_form_field_parser.dart. (-0.50 points)

Analysis of lib/common/parser/schema_switch_form_field_parser.dart reported 1 hint:

line 32 col 11: Close instances of dart.core.Sink.

Fix lib/common/parser/schema_text_parser.dart. (-0.50 points)

Analysis of lib/common/parser/schema_text_parser.dart reported 1 hint:

line 32 col 11: Close instances of dart.core.Sink.

Maintenance issues and suggestions

Support latest dependencies. (-30 points)

The version constraint in pubspec.yaml does not support the latest published versions for 3 dependencies (bloc, flutter_bloc, rxdart).

The description is too long. (-10 points)

Search engines display only the first part of the description. Try to keep the value of the description field in your package's pubspec.yaml file between 60 and 180 characters.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
bloc ^2.0.0 2.0.0 3.0.0
dynamic_widget ^1.0.5 1.0.6
equatable ^1.0.1 1.1.0
flutter 0.0.0
flutter_bloc ^2.1.1 2.1.1 3.2.0
intl >=0.14.0 <1.0.0 0.15.8 0.16.1
json_schema ^2.2.1 2.2.1
meta >=1.1.7 <2.0.0 1.1.8
path_provider ^1.4.5 1.6.1
rxdart ^0.22.6 0.22.6 0.23.1
Transitive dependencies
args 1.5.2
async 2.4.0
charcode 1.1.3
cli_repl 0.2.0+1
collection 1.14.11 1.14.12
colorize 2.0.0
dart2_constant 1.0.2+dart2
fluri 1.2.8
glob 1.2.0
http 0.12.0+4
http_parser 3.1.3
js 0.6.1+1
logging 0.11.4
matcher 0.12.6
mime 0.9.6+3
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.9.1
package_resolver 1.0.10
path 1.6.4
pedantic 1.9.0
platform 2.2.1
provider 3.2.0 4.0.4
quiver 2.1.2+1
sass 1.26.1
sky_engine 0.0.99
sockjs_client 0.3.5
sockjs_client_wrapper 1.0.14
source_maps 0.10.9
source_span 1.6.0
stack_trace 1.9.3
stream_transform 1.2.0
string_scanner 1.0.5
term_glyph 1.1.0
tuple 1.0.3
typed_data 1.1.6
uri 0.11.3+1
utf 0.9.0+5
vector_math 2.0.8
w_common 1.20.1
w_transport 3.2.8
watcher 0.9.7+13
Dev dependencies
effective_dart ^1.1.1
flutter_test