Sungguk Lim
Sungguk Lim

Reputation: 6228

create another function for deprecated name

class PubTools {
  void update(Context context, {bool force: false}) {
    // do something
  }
}

is Old code. and I'd like to change function name update to upgrade.

class PubTools {
  @deprecated
  void update(Context context, {bool force: false}) {
    upgrade(context, force);
  }
  void upgrade(Context context, {bool force: false}) {
    // do something
  }
}

But dartanalyzer returns warning.

something like..

[warning] 1 positional arguments expected, but 2 found (/home/sungguk/program_store/lib/grinder _utils.dart, line 130, col 8)

How can I remove warning? what's correct grammer?

Upvotes: 1

Views: 100

Answers (1)

Pixel Elephant
Pixel Elephant

Reputation: 21403

The {...} syntax denotes named parameters.

You must call the method by passing the name of the named parameter:

upgrade(context, force: force);

By not calling it with the parameter name it is treated as a positional parameter, but there is only one positional parameter expected for the upgrade method so it results in a warning.

Upvotes: 5

Related Questions