built_react 0.1.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 28

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

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: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]
75
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
30
Overall:
Weighted score of the above. [more]
28
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/src/element.built.g.dart. (-25 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. (-13.96 points)

Analysis of lib/generator.dart reported 30 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 31: The member 'CodeExpression' can only be used within 'package:code_builder/src/specs/expression/code.dart' or a test.

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. (-5.49 points)

Additional issues in the following files:

  • lib/src/element.dart (3 hints)
  • lib/bootstrap.g.dart (2 hints)
  • lib/src/bootstrap.dart (2 hints)
  • 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

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Running dartdoc failed with the following output: DetailedApiRequestError(status: 504, message: )

#0      _validateResponse (package:_discoveryapis_commons/src/clients.dart:852:9)
<asynchronous suspension>
#1      ApiRequester.request (package:_discoveryapis_commons/src/clients.dart:74:22)
<asynchronous suspension>
#2      ObjectsResourceApi.insert (package:googleapis/storage/v1.dart:3366:32)
#3      _MediaUploadStreamSink._startNormalUpload (package:gcloud/src/storage_impl.dart:599:10)
#4      new _MediaUploadStreamSink (package:gcloud/src/storage_impl.dart:514:9)
#5      _BucketImpl.write (package:gcloud/src/storage_impl.dart:179:16)
#6      uploadWithRetry.<anonymous closure> (package:pub_dev/shared/storage.dart:49:27)
<asynchronous suspension>
#7      retryAsync (package:pub_dev/shared/utils.dart:327:24)
<asynchronous suspension>
#8      uploadWithRetry (package:pub_dev/shared/storage.dart:47:9)
<asynchronous suspension>
#9      DartdocBackend.uploadDir.upload (package:pub_dev/dartdoc/backend.dart:137:13)
<asynchronous suspension>
#10     DartdocBackend.uploadDir.<anonymous closure> (package:pub_dev/dartdoc/backend.dart:149:64)
#11     Pool.withResource (package:pool/pool.dart:127:28)
<asynchronous suspension>
#12     DartdocBackend.uploadDir (package:pub_dev/dartdoc/backend.dart:149:39)
<asynchronous suspension>
#13     DartdocJobProcessor.process (package:pub_dev/dartdoc/dartdoc_runner.dart:249:30)
<asynchronous suspension>
#14     JobProcessor.run (package:pub_dev/job/job.dart:55:28)
<asynchronous suspension>
#15     JobMaintenance.run (package:pub_dev/job/job.dart:95:18)
#16     _workerMain.<anonymous closure> (package:pub_dev/service/entrypoint/dartdoc.dart:105:26)
#17     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
#18     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#19     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#20     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#21     _rootRunUnary (dart:async/zone.dart:1134:38)
#22     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#23     _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#24     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
#25     Future._propagateToListeners (dart:async/future_impl.dart:709:32)
#26     Future._completeWithValue (dart:async/future_impl.dart:524:5)
#27     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
#28     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
#29     DartdocJobProcessor.generateDocsForSdk (package:pub_dev/dartdoc/dartdoc_runner.dart)
#30     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
#31     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#32     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#33     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#34     _rootRunUnary (dart:async/zone.dart:1134:38)
#35     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#36     _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#37     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
#38     Future._propagateToListeners (dart:async/future_impl.dart:709:32)
#39     Future._completeWithValue (dart:async/future_impl.dart:524:5)
#40     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
#41     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
#42     VersionedJsonStorage.hasCurrentData (package:pub_dev/shared/storage.dart)
#43     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
#44     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#45     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#46     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#47     _rootRunUnary (dart:async/zone.dart:1134:38)
#48     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#49     _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#50     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
#51     Future._propagateToListeners (dart:async/future_impl.dart:709:32)
#52     Future._completeWithValue (dart:async/future_impl.dart:524:5)
#53     _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:32:15)
#54     _completeOnAsyncReturn (dart:async-patch/async_patch.dart:290:13)
#55     ApiRequester.request (package:_discoveryapis_commons/src/clients.dart)
#56     _asyncThenWrapperHelper.<anonymous closure> (dart:async-patch/async_patch.dart:73:64)
#57     StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#58     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#59     StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#60     _rootRunUnary (dart:async/zone.dart:1134:38)
#61     _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#62     _FutureListener.handleValue (dart:async/future_impl.dart:139:18)
#63     Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:680:45)
#64     Future._propagateToListeners (dart:async/future_impl.dart:709:32)
#65     Future._complete (dart:async/future_impl.dart:514:7)
#66     Stream.join.<anonymous closure> (dart:async/stream.dart:844:18)
#67     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#68     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#69     _rootRun (dart:async/zone.dart:1122:38)
#70     _CustomZone.run (dart:async/zone.dart:1023:19)
#71     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#72     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:391:13)
#73     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:401:15)
#74     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:285:7)
#75     _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:98:11)
#76     _EventSinkWrapper.close (dart:async/stream_transformers.dart:25:11)
#77     _StringAdapterSink.close (dart:convert/string_conversion.dart:251:11)
#78     _Utf8ConversionSink.close (dart:convert/string_conversion.dart:302:20)
#79     _ConverterStreamEventSink.close (dart:convert/chunked_conversion.dart:82:18)
#80     _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:143:24)
#81     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#82     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#83     _rootRun (dart:async/zone.dart:1122:38)
#84     _CustomZone.run (dart:async/zone.dart:1023:19)
#85     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#86     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:391:13)
#87     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:401:15)
#88     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:285:7)
#89     _ForwardingStream._handleDone (dart:async/stream_pipe.dart:108:10)
#90     _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:174:13)
#91     StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#92     StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#93     _rootRun (dart:async/zone.dart:1122:38)
#94     _CustomZone.run (dart:async/zone.dart:1023:19)
#95     _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#96     _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:391:13)
#97     _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:401:15)
#98     _BufferingStreamSubscription._close (dart:async/stream_impl.dart:285:7)
#99     _ForwardingStream._handleDone (dart:async/stream_pipe.dart:108:10)
#100    _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:174:13)
#101    StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#102    StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#103    _rootRun (dart:async/zone.dart:1122:38)
#104    _CustomZone.run (dart:async/zone.dart:1023:19)
#105    _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#106    _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:391:13)
#107    _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:401:15)
#108    _BufferingStreamSubscription._close (dart:async/stream_impl.dart:285:7)
#109    _SyncStreamControllerDispatch._sendDone (dart:async/stream_controller.dart:774:19)
#110    _StreamController._closeUnchecked (dart:async/stream_controller.dart:631:7)
#111    _StreamController.close (dart:async/stream_controller.dart:624:5)
#112    _HttpParser._closeIncoming (dart:_http/http_parser.dart:1039:23)
#113    _HttpParser._doParse (dart:_http/http_parser.dart:777:15)
#114    _HttpParser._parse (dart:_http/http_parser.dart:320:7)
#115    _HttpParser._onData (dart:_http/http_parser.dart:812:5)
#116    StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#117    StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#118    StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#119    _rootRunUnary (dart:async/zone.dart:1134:38)
#120    _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#121    _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
#122    _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:338:11)
#123    _BufferingStreamSubscription._add (dart:async/stream_impl.dart:265:7)
#124    _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:766:19)
#125    _StreamController._add (dart:async/stream_controller.dart:642:7)
#126    _StreamController.add (dart:async/stream_controller.dart:588:5)
#127    _Socket._onData (dart:io-patch/socket_patch.dart:1831:41)
#128    StackZoneSpecification._registerUnaryCallback.<anonymous closure>.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:26)
#129    StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#130    StackZoneSpecification._registerUnaryCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:129:14)
#131    _rootRunUnary (dart:async/zone.dart:1134:38)
#132    _CustomZone.runUnary (dart:async/zone.dart:1031:19)
#133    _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
#134    _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:338:11)
#135    _BufferingStreamSubscription._add (dart:async/stream_impl.dart:265:7)
#136    _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:766:19)
#137    _StreamController._add (dart:async/stream_controller.dart:642:7)
#138    _StreamController.add (dart:async/stream_controller.dart:588:5)
#139    _RawSecureSocket._sendReadEvent (dart:io/secure_socket.dart:1018:19)
#140    StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#141    StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#142    _rootRun (dart:async/zone.dart:1122:38)
#143    _CustomZone.run (dart:async/zone.dart:1023:19)
#144    _CustomZone.runGuarded (dart:async/zone.dart:925:7)
#145    _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:965:23)
#146    StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:209:15)
#147    StackZoneSpecification._registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:119:48)
#148    _rootRun (dart:async/zone.dart:1126:13)
#149    _CustomZone.run (dart:async/zone.dart:1023:19)
#150    _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:949:23)
#151    Timer._createTimer.<anonymous closure> (dart:async-patch/timer_patch.dart:23:15)
#152    _Timer._runTimers (dart:isolate-patch/timer_impl.dart:384:19)
#153    _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:418:5)
#154    _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)

Support latest dependencies. (-40 points)

The version constraint in pubspec.yaml does not support the latest published versions for 4 dependencies (analyzer, built_value, react, recase).

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.4
build ^1.0.0 1.1.0 1.2.2
built_collection ^4.0.0 4.3.2
built_value ^6.1.5 6.7.1 7.0.9
code_builder ^3.1.3 3.2.0 3.2.1
collection ^1.14.11 1.14.12
logging ^0.11.0 0.11.4
meta ^1.0.4 1.1.8
react ^4.5.0 4.9.2 5.3.0
recase ^2.0.1 2.0.1 3.0.0
source_gen ^0.9.1 0.9.4+1 0.9.5
Transitive dependencies
args 1.6.0
async 2.4.1
charcode 1.1.3
convert 2.1.1
crypto 2.1.4
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.9.3
path 1.6.4
pedantic 1.9.0
plugin 0.2.0+3
pub_semver 1.4.4
quiver 2.1.3
source_span 1.7.0
stack_trace 1.9.3
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+14
yaml 2.2.0
Dev dependencies
build_runner ^1.0.0
build_test any
build_web_compilers any
test any