tree_force 0.2.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 43

Tree Force #

A web ui framework based on a widget tree inspired by Flutter.

Experimental #

This package is in a proof-of-concept phase and is highly experimental. There is a good chance that the API will break with a new version of the package. Furthermore, don't expect high quality yet.

Roadmap #

  • Replace AngularDart in an internal use case (required features: some layout, images, text inputs, buttons, router, forms)
  • Optimize widget tree rebuild (currently the complete widget tree is rebuild even in the case a single leave has a state change)
  • Introduce keys for widgets in lists
  • Evaluate an in-code alternative for CSS
  • Implement more widgets
  • Tests
  • Documentation

Changelog #

0.1.0 #

  • Initial version

0.2.0 #

  • Added minified version of incremental-dom.
  • Bugfix: Fixed an exception, when tree_force is compiled with dart2js.

example/main.dart

import 'dart:async';

import 'package:tree_force/tree_force.dart';
import 'package:tree_force/tree_force_basic.dart';
import 'package:tree_force/tree_force_fx.dart';
import 'package:tree_force/tree_force_layout.dart';

void main() {
  treeForce(
      '#output',
      Opacity(
          opacity: 1.0,
          child: Padding(
              insets: Insets(top: pixel(20)),
              child: Stack(children: [
                Size(
                  width: percentage(100.0),
                  height: pixel(400),
                  child: Row(children: [
//                    Size(
//                        width: pixel(200),
//                        child: Align(
//                          vertical: VerticalAlignment.top,
//                          child: Image(
//                            title: 'Dart',
//                            src: 'dart.svg',
//                          ),
//                        )),
                    Column(children: [
                      SimpleStateless(),
                      SimpleStateful('state'),
                      StreamBuilder<int>(
                          initial: 0,
                          stream: Stream<int>.periodic(Duration(seconds: 2), (count) => count + 1),
                          builder: (state) {
                            return Text(text: 'builder: ${state}');
                          }),
                      Text(key: 'key1', text: 'E-Mail'),
                      Text(text: 'Nickname'),
                      Input(
                        placeholder: 'test',
                        initialValue: 'foo',
                        onInput: (text) => print('value of input: $text'),
                      ),
                    ]),
                    FlexItem(
                        flexGrow: 1,
                        child: Align(
                          vertical: VerticalAlignment.bottom,
                          child: Button.text(
                            text: 'Sign In',
                            classes: ['foo'],
                            onClick: () => print('button was clicked!'),
                          ),
                        )),
                  ]),
                ),
              ]))));
}

class SimpleStateless extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Row(
      children: [
        Text(text: 'Hello'),
        Margin(
          insets: Insets(left: pixel(10)),
          child: Text(text: 'World'),
        ),
      ],
    );
  }
}

class SimpleStateful extends StatefulWidget {
  final String prefix;

  SimpleStateful(this.prefix);

  @override
  State<StatefulWidget> createState() {
    return _SimpleState(this);
  }
}

class _SimpleState extends State<SimpleStateful> {
  int counter = 0;

  _SimpleState(SimpleStateful widget) : super(widget) {
    Timer.periodic(Duration(seconds: 1), (_) => setState(() => counter++));
  }

  @override
  Widget build(BuildContext context) {
    return Text(text: '${widget.prefix}: $counter');
  }

  @override
  String toString() {
    return '_SimpleState{counter: $counter}';
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  tree_force: ^0.2.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:tree_force/tree_force.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
86
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
43
Learn more about scoring.

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

  • Dart: 2.7.0
  • pana: 0.13.2

Health issues and suggestions

Document public APIs. (-0.08 points)

460 out of 475 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Fix lib/src/tree_force/framework.dart. (-2.48 points)

Analysis of lib/src/tree_force/framework.dart reported 5 hints:

line 42 col 12: Omit type annotations for local variables.

line 44 col 15: Prefer single quotes where they won't require escape sequences.

line 56 col 12: Omit type annotations for local variables.

line 86 col 5: Prefer using ??= over testing for null.

line 199 col 11: Unnecessary new keyword.

Fix lib/src/tree_force/html_node.dart. (-2.48 points)

Analysis of lib/src/tree_force/html_node.dart reported 5 hints:

line 44 col 5: Don't access members with this unless avoiding shadowing.

line 48 col 5: Don't access members with this unless avoiding shadowing.

line 52 col 5: Don't access members with this unless avoiding shadowing.

line 56 col 5: Don't access members with this unless avoiding shadowing.

line 57 col 5: Don't access members with this unless avoiding shadowing.

Fix lib/src/tree_force/widget.dart. (-2.48 points)

Analysis of lib/src/tree_force/widget.dart reported 5 hints:

line 33 col 18: Annotate overridden members.

line 60 col 28: Annotate overridden members.

line 74 col 29: Annotate overridden members.

line 86 col 27: Annotate overridden members.

line 168 col 15: Don't access members with this unless avoiding shadowing.

Fix additional 24 files with analysis or formatting issues. (-6.99 points)

Additional issues in the following files:

  • lib/src/tree_force_basic/style.dart (3 hints)
  • lib/src/tree_force/html_tag.dart (2 hints)
  • lib/src/tree_force_basic/checkbox.dart (2 hints)
  • lib/src/tree_force_layout/size.dart (2 hints)
  • lib/src/tree_force/incremental_dom.dart (1 hint)
  • lib/src/tree_force_basic/input.dart (1 hint)
  • lib/src/tree_force_basic/list.dart (1 hint)
  • lib/src/tree_force_form/form.dart (1 hint)
  • lib/src/tree_force_layout/flex.dart (1 hint)
  • lib/src/tree_force/change_listener.dart (Run dartfmt to format lib/src/tree_force/change_listener.dart.)
  • lib/src/tree_force/input_listener.dart (Run dartfmt to format lib/src/tree_force/input_listener.dart.)
  • lib/src/tree_force/interaction_listener.dart (Run dartfmt to format lib/src/tree_force/interaction_listener.dart.)
  • lib/src/tree_force/length.dart (Run dartfmt to format lib/src/tree_force/length.dart.)
  • lib/src/tree_force_basic/builder.dart (Run dartfmt to format lib/src/tree_force_basic/builder.dart.)
  • lib/src/tree_force_basic/button.dart (Run dartfmt to format lib/src/tree_force_basic/button.dart.)
  • lib/src/tree_force_basic/image.dart (Run dartfmt to format lib/src/tree_force_basic/image.dart.)
  • lib/src/tree_force_basic/label.dart (Run dartfmt to format lib/src/tree_force_basic/label.dart.)
  • lib/src/tree_force_basic/router.dart (Run dartfmt to format lib/src/tree_force_basic/router.dart.)
  • lib/src/tree_force_form/form_field.dart (Run dartfmt to format lib/src/tree_force_form/form_field.dart.)
  • lib/src/tree_force_layout/align.dart (Run dartfmt to format lib/src/tree_force_layout/align.dart.)
  • lib/src/tree_force_layout/fixed.dart (Run dartfmt to format lib/src/tree_force_layout/fixed.dart.)
  • lib/src/tree_force_layout/scroll_box.dart (Run dartfmt to format lib/src/tree_force_layout/scroll_box.dart.)
  • lib/src/tree_force_layout/stack.dart (Run dartfmt to format lib/src/tree_force_layout/stack.dart.)
  • lib/src/tree_force_redux/store_connector.dart (Run dartfmt to format lib/src/tree_force_redux/store_connector.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 (redux).

Homepage URL is insecure. (-5 points)

Update the homepage field and use a secure (https) URL.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
redux ^3.0.0 3.0.0 4.0.0
vector_math ^2.0.8 2.0.8
Dev dependencies
build_runner ^0.9.1
build_web_compilers ^0.4.0