DartSDK: 1.24.2
https://stackoverflow.com/questions/46219087/nullerror-method-not-found-appendchild-on-null
Client part of application: https://github.com/Rasarts/lko_client_only
_pubspec.yaml:_
environment:
sdk: '>=1.24.2'
dependencies:
angular: '^4.0.0'
angular_forms: '^1.0.0'
angular_router: '^1.0.2'
angular_components: '^0.6.0'
transformers:
- angular:
entry_points:
- web/main.dart
- test/client/**_test.dart
- test/pub_serve:
$include: test/**_test{.*,}.dart
- $dart2js:
commandLineOptions: [--trust-type-annotations, --trust-primitives, --show-package-warnings, --dump-info]
- dart_to_js_script_rewriter
--mode="debug"
When I run rm -rf .pub && pub upgrade && pub build --mode="debug" I get warrnings in terminal:
[Warning from Dart2JS on web_lko|web/main.dart]:
web/packages/angular_components/src/utils/async/src/zoned_async.dart:14:30:
Method type variables are treated as `dynamic` in `as` expressions.
Try using the upper bound of the type variable, or check that the blind success of the test does not introduce bugs.
S _runInZone<S>(S fn()) => _runInZoneFn(fn) as S;
^^^^^^^^^^^^^^^^^^^^^
[Warning from Dart2JS on web_lko|web/main.dart]:
web/packages/angular_components/src/utils/angular/managed_zone/angular_2.dart:59:30:
Method type variables are treated as `dynamic` in `as` expressions.
Try using the upper bound of the type variable, or check that the blind success of the test does not introduce bugs.
T runOutside<T>(T fn()) => _ngZone.runOutsideAngular(fn) as T;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Warning from Dart2JS on web_lko|web/main.dart]:
web/packages/angular/src/core/linker/app_view.dart:590:17:
Method type variables are treated as `dynamic` in `as` expressions.
Try using the upper bound of the type variable, or check that the blind success of the test does not introduce bugs.
handler(event as F);
^^^^^^^^^^
[Warning from Dart2JS on web_lko|web/main.dart]:
web/packages/angular/src/core/linker/app_view.dart:594:39:
Method type variables are treated as `dynamic` in `as` expressions.
Try using the upper bound of the type variable, or check that the blind success of the test does not introduce bugs.
.runGuarded(() => handler(event as F));
^^^^^^^^^^
[Warning from Dart2JS on web_lko|web/main.dart]:
web/packages/angular_components/src/components/material_tree/src/material_tree_node.dart:188:9:
Variable 'option' is not shown to have type 'MaterialTreeExpandState' because 'MaterialTreeExpandState' is not a subtype of the known type 'MaterialTreeNode.T' of 'option'.
if (option is MaterialTreeExpandState) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[Warning from Dart2JS on web_lko|web/main.dart]:
web/packages/angular_components/src/components/material_tree/src/material_tree_node.dart:189:7:
The setter 'expanded' is not defined for the class 'T'.
option.expanded = state;
But no warnings in browser console when I open compiled index.html
--mode="release"
When I run rm -rf .pub && pub upgrade && pub build --mode="release" errors on build still there, but in browser console I get exception and error:
main.dart.js:10583 EXCEPTION: NullError: method not found: 'appendChild' on null
STACKTRACE:
TypeError: Cannot read property 'appendChild' of null
at EN.$0 (https://localhost:8282/main.dart.js:9422:3)
at EU.dart.EU.$0 (https://localhost:8282/main.dart.js:9393:14)
at N7.dart.x3.func (https://localhost:8282/main.dart.js:3058:35)
at bK.dart.bK.E8 (https://localhost:8282/main.dart.js:10339:7)
at Object.eval (eval at qf (https://localhost:8282/main.dart.js:1851:15), <anonymous>:2:41)
at Qw.aY (https://localhost:8282/main.dart.js:4346:12)
at bK.aY (https://localhost:8282/main.dart.js:10386:30)
at pY.aY (https://localhost:8282/main.dart.js:9314:3)
at pY.z4 (https://localhost:8282/main.dart.js:9317:28)
at https://localhost:8282/main.dart.js:9289:12
ORIGINAL EXCEPTION: NullError: method not found: 'appendChild' on null
(anonymous) @ main.dart.js:10583
main.dart.js:1251 Uncaught Error: NullError: method not found: 'appendChild' on null
at EN.$0 (main.dart.js:9422)
at EU.dart.EU.$0 (main.dart.js:9393)
at N7.dart.x3.func (main.dart.js:3058)
at bK.dart.bK.E8 (main.dart.js:10339)
at Object.eval (eval at qf (main.dart.js:1851), <anonymous>:2:41)
at Qw.aY (main.dart.js:4346)
at bK.aY (main.dart.js:10386)
at pY.aY (main.dart.js:9314)
at pY.z4 (main.dart.js:9317)
at main.dart.js:9289
I didn't use dartdevc for now.
Somethings wrong with release mode?
@Rasarts You can safely ignore the dart2js warnings you see above, we're in a transitional period (Dart 2.x/strong-mode), and some code that is needed to satisfy dartdevc triggers some safe-to-ignore warnings in dart2js.
I'd need to see a stack trace with source maps and/or in dartdevc and/or Dartium to better help diagnose if the error is with AngularDart, or your own code. I don't think this is an SDK issue though @a-siva, you can move over to dart-lang/angular.
How can I make a stack trace output with source maps: pub --trace build --mode="release"? For dartium?
The same problem. When building in debug mode everything works fine. When building in release mode the following error occurs in the browser console:
EXCEPTION: NullError: method not found: 'appendChild' on null
STACKTRACE:
TypeError: Cannot read property 'appendChild' of null
at ji.$0 (http://localhost:8000/main.dart.js:5607:2)
at jp.dart.jp.$0 (http://localhost:8000/main.dart.js:5578:14)
at lW.dart.fI.func (http://localhost:8000/main.dart.js:2230:24)
at fx.dh (http://localhost:8000/main.dart.js:2977:12)
at ax.dart.ax.hd (http://localhost:8000/main.dart.js:5915:5)
at Object.eval (eval at dX (http://localhost:8000/main.dart.js:1366:15), <anonymous>:2:41)
at mD.D (http://localhost:8000/main.dart.js:3050:12)
at ax.D (http://localhost:8000/main.dart.js:5957:29)
at dS.D (http://localhost:8000/main.dart.js:5505:3)
at dS.f2 (http://localhost:8000/main.dart.js:5508:28)
ORIGINAL EXCEPTION: NullError: method not found: 'appendChild' on null
Source map is impossible to get because in release mode pub build does not generates source map
@jakemac53 @kevmoo Is it possible to use release mode with source maps?
Ya, lets close this as not planned/obsolete based on new changes
@jakemac53 Wrong issue closed?
haha whoops!
I don't know of a way to enable sourcemaps though in release mode, but one might exist.
I have found the reason of this behavior in my case. It was my fault: wrong way of script loading.
Correct:
<script defer src="main.dart" type="application/dart"></script>
<script defer src="packages/browser/dart.js"></script>
Incorrect:
<script src="main.dart" type="application/dart"></script>
<script src="packages/browser/dart.js"></script>
I'm sorry for disturbing
Yes, it's worked for me.
<script defer type="application/dart" src="main.dart"></script>
<script defer src="packages/browser/dart.js"></script>
Thanks.
Hello, I have the same problem , can you please, provide me with explanation about this warning I am trying to solve it and I am not sure about the main cause for it.
[Info from Dart2JS]:
web/packages/angular/src/core/linker/app_view.dart:590:17:
Method type variables are treated as `dynamic` in `as` expressions.
Try using the upper bound of the type variable, or check that the blind success of the test does not introduce bugs.
handler(event as F);
^^^^^^^^^^
web/packages/angular/src/core/linker/app_view.dart:594:39:
Method type variables are treated as `dynamic` in `as` expressions.
Try using the upper bound of the type variable, or check that the blind success of the test does not introduce bugs.
.runGuarded(() => handler(event as F));
^^^^^^^^^^
web/packages/angular/src/core/linker/app_view_utils.dart:343:45:
Method type variables are treated as `dynamic` in `as` expressions.
Try using the upper bound of the type variable, or check that the blind success of the test does not introduce bugs.
T castByValue<T>(dynamic input, T value) => input as T;
^^^^^^^^^^
web/packages/js_wrapping/js_wrapping.dart:43:56:
Method type variables are treated as `dynamic` in `as` expressions.
Try using the upper bound of the type variable, or check that the blind success of the test does not introduce bugs.
T asJsObject<T extends JsObject>(JsRef<JsObject> o) => o._value as T;
^^^^^^^^^^^^^
I already use:
<script defer src="main.dart" type="application/dart"></script>
<script defer src="packages/browser/dart.js"></script>
thank you.
@eftikharEmad That doesn't look related.
You can safely ignore "info" messages for now.
I'm closing this as stale.
Most helpful comment
I have found the reason of this behavior in my case. It was my fault: wrong way of script loading.
Correct:
Incorrect:
I'm sorry for disturbing