"NoSuchCapabilityError: no capability to invoke the method" when assigning an action to a button

Issue

main_app.html:

<dom-module id="main-app">
  *snip*
  <template>
    *snip*
      <paper-button on-tap="nextStep" raised>Next step</paper-button>
      <p>The step is {{step}}</p>
  </template>
</dom-module>

main_app.dart:

@HtmlImport('main_app.html')

*snip*

@PolymerRegister('main-app')
class MainApp extends PolymerElement {
  *snip*

  @property int step = 0;

  MainApp.created() : super.created();

  *snip*

  @reflectable
  void nextStep() {
      step = step + 1;
      print('Next step!');
  }
}

When I run this and press the button, I get this error in Dartium’s console:

NoSuchCapabilityError: no capability to invoke the method 'nextStep'

What am I doing wrong?

Solution

Please try

void nextStep(event, [_]) {

or

void nextStep([_, __]) {

Answered By – Günter Zöchbauer

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *