schema_widget 0.1.8

  • Readme
  • Changelog
  • Example
  • Installing
  • 58

schema_widget #

A Flutter package for dynamic widget creation.

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

[0.0.1] - Initial commit. #

  • Added initial widgets from DynamicWidgets.

[0.0.2] - Add more widgets. #

  • Added more widgets.

[0.1.0] - Refactor. #

  • Added more widgets;
  • Refactor and unify builder method of class SchemaWidget;
  • Implement example.

[0.1.1] - Change dependency of json_schema #

  • Change json_schema version from 3.0.0 to 2.2.1.

[0.1.2] - Add StreamBuilder parser #

  • Added StreamBuilder parser;
  • Change google_maps_flutter version from 0.5.21+17 to 0.5.22.

[0.1.3] - Better invalid schema log #

  • More detailed message on schema invalid;
  • Change get_it version from 3.1.0 to 4.0.0;
  • Change google_maps_flutter version from 0.5.22 to 0.5.24+1;
  • Change flutter spinkit version from 4.1.1+1 to 4.1.2.

[0.1.4] - Add properties on AppBar parser #

  • Add many properties on AppBarSchemaWidgetParser.

[0.1.5] - Add properties on MaterialApp parser #

  • Add many properties on MaterialAppSchemaWidgetParser.

[0.1.6] - Tuning parsers null safe #

  • Verify for null values during parsers.

[0.1.7] - Infer default values on MaterialApps parser properties #

  • Infer default values in properties added on MaterialApps parser.

[0.1.8] - Change register logic to permit override #

  • Alter implementation of registerLogic to permit alteration of logics registered.

example/lib/main.dart

import 'dart:async';

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

void main() {
  SchemaWidget.registerParsers();

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return SchemaWidget.build(context, {
      "type": "MaterialApp",
      "title": 'Flutter Demo',
      "theme": ThemeData(
        primarySwatch: Colors.blue,
      ),
      "home": MyHomePage(title: 'Flutter Demo Home Page'),
    });
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  final StreamController<int> _streamControllerInt = StreamController<int>();

  _MyHomePageState() {
    SchemaWidget.registerLogic("streamInt", _streamControllerInt.stream);
    SchemaWidget.registerLogic("buildTextCounter", _buildTextCounter);
  }

  void _incrementCounter() {
    _streamControllerInt.add(++_counter);
  }

  Widget _buildTextCounter(
      BuildContext buildContext, AsyncSnapshot<dynamic> snapshot) {
    var textStyle = Theme.of(buildContext).textTheme.display1;

    return SchemaWidget.build(buildContext, {
      "type": "Text",
      "data": '${snapshot.data}',
      "style": {
        "type": "TextStyle",
        "color": "#${intToHex(textStyle.color.value, 6)}",
        "debugLabel": textStyle.debugLabel,
        "decoration": textDecorationToString(textStyle.decoration),
        "fontFamily": textStyle.fontFamily,
        "fontSize": textStyle.fontSize,
        "fontWeight": textStyle.fontWeight.toString().substring(11),
        "fontStyle":
            textStyle.fontStyle == FontStyle.italic ? 'italic' : 'normal',
      },
    });
  }

  @override
  Widget build(BuildContext context) {
    var iconData = Icons.add;

    return SchemaWidget.build(context, {
      "type": "Scaffold",
      "appBar": {
        "type": "AppBar",
        "title": {
          "type": "Text",
          "data": widget.title,
        },
      },
      "body": {
        "type": "Center",
        "child": {
          "type": "Column",
          "mainAxisAlignment": "center",
          "children": [
            {
              "type": "Text",
              "data": 'You have pushed the button this many times:',
            },
            {
              "type": "StreamBuilder",
              "stream": "streamInt",
              "initialData": _counter,
              "builder": "buildTextCounter",
            },
          ],
        },
      },
      "floatingActionButton": {
        "type": "FloatingActionButton",
        "onPressed": _incrementCounter,
        "tooltip": 'Increment',
        "child": {
          "type": "Icon",
          "codePoint": "#${intToHex(iconData.codePoint, 5)}",
          "fontFamily": iconData.fontFamily,
          "matchTextDirection": iconData.matchTextDirection,
        },
      },
    });
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  schema_widget: ^0.1.8

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

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

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

Health issues and suggestions

Fix lib/utils.dart. (-5.48 points)

Analysis of lib/utils.dart reported 1 warning, 1 hint:

line 532 col 10: The parameter 'shape' is required. .

line 170 col 6: Don't explicitly initialize variables to null.

Fix lib/parser/indexed_stack_schema_widget_parser.dart. (-1 points)

Analysis of lib/parser/indexed_stack_schema_widget_parser.dart reported 2 hints:

line 18 col 8: Don't import implementation files from another package.

line 19 col 8: Don't import implementation files from another package.

Fix lib/parser/align_schema_widget_parser.dart. (-0.50 points)

Analysis of lib/parser/align_schema_widget_parser.dart reported 1 hint:

line 18 col 8: Don't import implementation files from another package.

Fix additional 41 files with analysis or formatting issues. (-19 points)

Additional issues in the following files:

  • lib/parser/app_bar_schema_widget_parser.dart (1 hint)
  • lib/parser/aspect_ratio_schema_widget_parser.dart (1 hint)
  • lib/parser/asset_image_schema_widget_parser.dart (1 hint)
  • lib/parser/baseline_schema_widget_parser.dart (1 hint)
  • lib/parser/center_schema_widget_parser.dart (1 hint)
  • lib/parser/clip_r_rect_schema_widget_parser.dart (1 hint)
  • lib/parser/column_schema_widget_parser.dart (1 hint)
  • lib/parser/container_schema_widget_parser.dart (1 hint)
  • lib/parser/divider_schema_widget_parser.dart (1 hint)
  • lib/parser/drawer_header_schema_widget_parser.dart (1 hint)
  • lib/parser/drawer_schema_widget_parser.dart (1 hint)
  • lib/parser/expanded_schema_widget_parser.dart (1 hint)
  • lib/parser/expanded_sized_box_schema_widget_parser.dart (1 hint)
  • lib/parser/fitted_box_schema_widget_parser.dart (1 hint)
  • lib/parser/floating_action_button_schema_widget_parser.dart (1 hint)
  • lib/parser/gesture_detector_schema_widget_parser.dart (1 hint)
  • lib/parser/google_map_schema_widget_parser.dart (1 hint)
  • lib/parser/grid_view_schema_widget_parser.dart (1 hint)
  • lib/parser/icon_schema_widget_parser.dart (1 hint)
  • lib/parser/list_tile_schema_widget_parser.dart (1 hint)
  • lib/parser/list_view_schema_widget_parser.dart (1 hint)
  • lib/parser/material_app_schema_widget_parser.dart (1 hint)
  • lib/parser/network_image_schema_widget_parser.dart (1 hint)
  • lib/parser/opacity_schema_widget_parser.dart (1 hint)
  • lib/parser/padding_schema_widget_parser.dart (1 hint)
  • lib/parser/page_view_schema_widget_parser.dart (1 hint)
  • lib/parser/placeholder_schema_widget_parser.dart (1 hint)
  • lib/parser/positioned_schema_widget_parser.dart (1 hint)
  • lib/parser/raised_button_schema_widget_parser.dart (1 hint)
  • lib/parser/row_schema_widget_parser.dart (1 hint)
  • lib/parser/safe_area_schema_widget_parser.dart (1 hint)
  • lib/parser/scaffold_schema_widget_parser.dart (1 hint)
  • lib/parser/sized_box_schema_widget_parser.dart (1 hint)
  • lib/parser/spin_kit_rotating_circle_schema_widget_parser.dart (1 hint)
  • lib/parser/stack_schema_widget_parser.dart (1 hint)
  • lib/parser/stream_builder_schema_widget_parser.dart (1 hint)
  • lib/parser/text_schema_widget_parser.dart (1 hint)
  • lib/parser/wrap_schema_widget_parser.dart (1 hint)
  • lib/schema_widget.dart (Run flutter format to format lib/schema_widget.dart.)
  • lib/state/grid_view_widget_state.dart (Run flutter format to format lib/state/grid_view_widget_state.dart.)
  • lib/state/list_view_widget_state.dart (Run flutter format to format lib/state/list_view_widget_state.dart.)

Maintenance suggestions

The package description is too short. (-14 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_spinkit ^4.1.2 4.1.2+1
get_it ^4.0.1 4.0.1
google_maps_flutter ^0.5.25+1 0.5.25+2
http ^0.12.0+4 0.12.0+4
json_schema ^2.2.1 2.2.1
logging ^0.11.4 0.11.4
Transitive dependencies
args 1.6.0
async 2.4.1
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
flutter_plugin_android_lifecycle 1.0.6
glob 1.2.0
http_parser 3.1.4
intl 0.16.1
js 0.6.1+1
matcher 0.12.6
meta 1.1.8
mime 0.9.6+3
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.9.3
package_resolver 1.0.10
path 1.6.4
pedantic 1.9.0
quiver 2.1.3
sass 1.26.3
sky_engine 0.0.99
sockjs_client 0.3.5
sockjs_client_wrapper 1.0.14
source_maps 0.10.9
source_span 1.7.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.2
w_transport 3.2.8
watcher 0.9.7+14
Dev dependencies
effective_dart ^1.2.1
flutter_test