Daniel Robinson
Daniel Robinson

Reputation: 14848

why am I getting type error on polymer.dart element?

I have some code:

// main.dart:
void main{
  initPolymer();
  var view = new ChatAppConsumer();
}

//chat_app.dart
@CustomTag('chat-app')
class ChatApp extends PolymerElement{
  ChatApp.created():super.created();
}

class ChatAppConsumer{
  final ChatApp view = new Element.tag('chat-app');
}

as far as I can tell I have all my files properly referenced and Im calling initPolymer(); before I attempt to create my custom tag, but I get the type error that the HtmlElement returned by new Element.tag('chat-app'); is not of typeChatApp` but I use this exact same pattern in another package I have and it works perfectly there. Anyone come across something like this before?

Upvotes: 2

Views: 84

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657048

initPolymer is not enough, you should pass a closure to initPolymer.run(() => ...) which executes your Polymer related code.

See how to implement a main function in polymer apps for more details

= Polymer 0.16.0 // main.dart: void main{ initPolymer().then((zone) => zone.run(() { var view = new ChatAppConsumer(); })); }

< Polymer 0.16.0

// main.dart:
void main{
  initPolymer().run(() {
    var view = new ChatAppConsumer();
  });
}

Upvotes: 2

Related Questions