0

I'm trying to toggle drawer panel in Dart, but it throws type 'HtmlElement' is not a subtype of type 'CoreDrawerPanel' of 'panel'. on line CoreDrawerPanel panel = querySelector('#drawerPanel');

Here is my dart:

import 'dart:html';
import 'package:core_elements/core_drawer_panel.dart';

void main() {
  querySelector('#navicon')
    ..onClick.listen(naviconClick);
}

void naviconClick(Event event) {
  CoreDrawerPanel panel = querySelector('#drawerPanel');
  panel.togglePanel();
}

And here is my HTML:

    <core-drawer-panel id="drawerPanel">
      <core-header-panel drawer>
        <core-toolbar>Menu</core-toolbar>
        <core-menu>
          <core-item label="One"></core-item>
          <core-item label="Two"></core-item>
        </core-menu>
      </core-header-panel>
      <core-header-panel main>
        <core-toolbar>
          <core-icon-button id="navicon" icon="menu"></core-icon-button>
          <div>Project</div>
        </core-toolbar>
        <div class="content">
        </div>
      </core-header-panel>
    </core-drawer-panel>      

Thanks for answers.

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Václav Pavlíček
  • 419
  • 2
  • 9
  • 21
  • What's the exact error thrown? – Günter Zöchbauer May 03 '15 at 15:05
  • type 'HtmlElement' is not a subtype of type 'CoreDrawerPanel' of 'panel'. this error it throws – Václav Pavlíček May 03 '15 at 15:06
  • If you have a custom `main()` method you need to ensure Polymer initialization is done before accessing Polymer elements content. – Günter Zöchbauer May 03 '15 at 15:08
  • when i'm trying init polymer( initPolymer().run(() {...) DartEditor throws warning The method 'run' is not defined for the class 'Future' , and i have imported polymer package – Václav Pavlíček May 03 '15 at 15:24
  • 1
    The answer to my referenced question contains 3 different ways to initialize Polymer in a custom main. Your Polymer version probably requires the 1st or 2nd way but you used the 3rd. Try renaming `main` to something else and add `@whenPolymerReady` as shown in my answer. – Günter Zöchbauer May 03 '15 at 15:26

0 Answers0