built_react 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 27

built-react #

Simple typesafe dart react.

Usage #

A simple usage example:

<!DOCTYPE html>

<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Example</title>
    <script defer src="packages/react/react.js"></script>
    <script defer src="packages/react/react_dom.js"></script>
    <script defer src="main.dart.js"></script>
</head>

<body>
<div id="react">Loading...</div>
</body>
</html>
import 'package:built_react/built_react.dart';

part 'main.g.dart';

abstract class AppProps implements BuiltSimple, Props {
  factory AppProps([BuilderFunc<AppPropsBuilder> b]) => _AppProps(b);
  String get text;
}

class App extends Component {
  @override
  AppProps get props => super.props;

  App([BuilderFunc<AppPropsBuilder> b, List<RenderResult> c]) : super(AppProps(b), c);

  @override
  RenderResult render() {
    return Dom.div(
        (b) => b
          ..className.add('example')
          ..on.click = ((e) => window.alert(''))
          ..style.position = PositionValue.fixed
          ..style.right = Size.px(100)
          ..style.top = Size.px(100),
        [Text(props.text)]);
  }
}

main() {
  render(App((b) => b..text = 'Hello world!'), '#react');
}

License #

BSD-3-Clause.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

Changelog #

0.1.1 #

  • Forgot generated files.

0.1.0 #

  • Initial version.

example/main.dart

import 'package:built_react/built_react.dart';
import 'dart:html';

part 'main.g.dart';

abstract class AppProps implements BuiltSimple, Props {
  factory AppProps([BuilderFunc<AppPropsBuilder> b]) => _AppProps(b);
  String get text;
}

class App extends Component {
  @override
  AppProps get props => super.props;

  App([BuilderFunc<AppPropsBuilder> b, List<RenderResult> c]) : super(AppProps(b), c);

  @override
  RenderResult render() {
    return Dom.div(
        (b) => b
          ..className.add('example')
          ..on.click = ((e) => window.alert(''))
          ..style.position = PositionValue.fixed
          ..style.right = Size.px(100)
          ..style.top = Size.px(100),
        [Text(props.text)]);
  }
}

main() {
  render(App((b) => b..text = 'Click me!'), '#react');
}

Use this package as a library

1. Depend on it

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


dependencies:
  built_react: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:built_react/built_react.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
56
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
50
Overall:
Weighted score of the above. [more]
27
Learn more about scoring.

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

  • Dart: 2.6.0
  • pana: 0.12.21

Platforms

Detected platforms: web

Primary library: package:built_react/built_react.dart with components: html, js.

Health suggestions

Fix lib/src/element.built.g.dart. (-32.70 points)

Analysis of lib/src/element.built.g.dart reported 79 hints, including:

line 270 col 19: Unnecessary new keyword.

line 375 col 19: Unnecessary new keyword.

line 613 col 19: Unnecessary new keyword.

line 664 col 19: Unnecessary new keyword.

line 720 col 19: Unnecessary new keyword.

Fix lib/generator.dart. (-10.89 points)

Analysis of lib/generator.dart reported 23 hints, including:

line 133 col 57: Use = to separate a named parameter from its default value.

line 151 col 86: Use = to separate a named parameter from its default value.

line 236 col 16: Use isEmpty instead of length

line 250 col 27: Unnecessary new keyword.

line 250 col 46: Unnecessary new keyword.

Fix lib/src/component.dart. (-1.99 points)

Analysis of lib/src/component.dart reported 4 hints:

line 2 col 38: Use lowercase_with_underscores when specifying a library prefix.

line 3 col 42: Use lowercase_with_underscores when specifying a library prefix.

line 78 col 58: Use isEmpty instead of length

line 223 col 10: Don't explicitly initialize variables to null.

Fix additional 12 files with analysis or formatting issues. (-4.99 points)

Additional issues in the following files:

  • lib/src/element.dart (3 hints)
  • lib/bootstrap.g.dart (2 hints)
  • lib/src/bootstrap.dart (1 hint)
  • lib/src/click_outside_handler.dart (1 hint)
  • lib/src/click_outside_handler.g.dart (1 hint)
  • lib/src/element.built.dart (1 hint)
  • lib/src/element.g.dart (1 hint)
  • lib/bootstrap.dart (Run dartfmt to format lib/bootstrap.dart.)
  • lib/builder.dart (Run dartfmt to format lib/builder.dart.)
  • lib/src/base.dart (Run dartfmt to format lib/src/base.dart.)
  • lib/src/built_simple.dart (Run dartfmt to format lib/src/built_simple.dart.)
  • lib/src/style.dart (Run dartfmt to format lib/src/style.dart.)

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 (analyzer, built_value, react).

The package description is too short. (-20 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.0.0-dev <3.0.0
analyzer >=0.33.3 <0.35.0 0.34.3 0.39.1
build ^1.0.0 1.1.0 1.2.2
built_collection ^4.0.0 4.3.0
built_value ^6.1.5 6.7.1 7.0.0
code_builder ^3.1.3 3.2.0 3.2.1
collection ^1.14.11 1.14.12
logging ^0.11.0 0.11.3+2
meta ^1.0.4 1.1.8
react ^4.5.0 4.9.2 5.1.1
recase ^2.0.1 2.0.1
source_gen ^0.9.1 0.9.4+1 0.9.4+6
Transitive dependencies
args 1.5.2
async 2.4.0
charcode 1.1.2
convert 2.1.1
crypto 2.1.3
csslib 0.16.1
dart_style 1.2.3 1.3.3
fixnum 0.10.11
front_end 0.1.9+1 0.1.29
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
kernel 0.3.9+1 0.3.29
matcher 0.12.6
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.1.0
path 1.6.4
pedantic 1.8.0+1
plugin 0.2.0+3
pub_semver 1.4.2
quiver 2.1.2+1
source_span 1.5.5
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+13
yaml 2.2.0
Dev dependencies
build_runner ^1.0.0
build_test any
build_web_compilers any
test any