Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

dart - Suppress hint about use of protected member

The meta package provides a @protected annotation (besides others) to get analyzer hints or warnings about the use of protected members outside of direct subclasses.

INFO: The member 'selectedChildrenChanged' can only be used within instance members of subclasses of 'MenuItem' ([bwu_ng_quick_nav] test/menu_item_test.dart:108)

I'm not interested in these hints in my unit tests.

How can I suppress such hints?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The suppression code for the @protected hint is INVALID_USE_OF_PROTECTED_MEMBER. Add a suppression comment like:

  // ignore: INVALID_USE_OF_PROTECTED_MEMBER
  app.quickNav.keyDownHandler(ctrlKeyDown);

or

   // ignore_for_file: INVALID_USE_OF_PROTECTED_MEMBER

The codes for other hints can be found in

This works with Dart VM version: 1.16.0-edge. I don't know with what version this was released.

Hopefully these IDs will be part of the warnings soon to not have to look them up.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...