Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio suppress warnings

Recently updated to Android Studio 3.5 and now my code is full of annoying yellow lines with warning that I would like to suppress.

However, when trying clicking on the yellow bulb and use the solution proposed, it does not work, it just adds a comment-like line that has no effect, example:

When getting this warning:

"Use => for short members whose body is a single return statement"

Yellow bulb just adds a line above like this:

// ignore: prefer_expression_function_bodies

Any permanent solution to these annoying warnings in Android Studio?

like image 775
codeKiller Avatar asked Oct 21 '25 01:10

codeKiller


1 Answers

The Dart analyzer does this and the ignore comment should suppress the warnings. By the way, this should not have anything to do with your Android Studio version.

There are two main ways to suppress specific lints "globally":

  • Use ignore_for_file comments. This is analogous to ignore, but works for the whole file.
    Simply add the following somewhere:
// ingore_for_file: prefer_expression_function_bodies
  • Specify exclusions in your analysis_options.yaml file. You can always view documentation for all the lints, e.g. for prefer_expression_function_bodies, and any lint can be excluded in your analysis_options.yaml file (it should be placed in the same directory as your pubspec.yaml):
linter:
  rules:
    prefer_expression_function_bodies: false

Learn more.

like image 192
creativecreatorormaybenot Avatar answered Oct 22 '25 14:10

creativecreatorormaybenot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!