Dart confusing TYPE error

2019-06-18 22:13发布

问题:

I am building a web application using dart with web_ui.

Everything was working fine until i added the web_ui pub, and now, when I am trying to run a build.dart file I get an error:

Uncaught Error: type 'AttributeName' is not a subtype of type 'String' of 'name'.

What does this mean?

From what I understand, this means there is somewhere an instance named 'name' of class 'AttributeName' that is extending 'String' class.

I searched my entire project and there is nowhere a class named 'AttributeName', nowhere an instance of 'name'.

I have the latest Dart editor and SDK:

Dart Editor version 0.4.7_r21658
Dart SDK version 0.4.7.5_r21658

EDIT: this is my build.dart file:

import 'package:web_ui/component_build.dart';
import 'dart:io';

void main() {
  build(new Options().arguments, ['web/menyplattan.html']);
}

Also, i updated all the pubs

回答1:

This message looks like web_ui is failing a type check.

The similar SO question MarioP links to has a stacktrace showing this message coming from within the web ui library itself.

Do you have an xmlns attribute in your html? Have a look at this web-ui issue.

AttributeName is defined within the html5lib library. Perhaps web-ui is expecting a newer version of this library but getting an older one. Make sure you've done a pub install. You can also try deleting your packages folder and doing a fresh pub install.

This could be caused by out-of-date packages, but it could also be a bug in web-ui. See if you can get a stacktrace and file a bug report, or post it on the web-ui mailing list.