Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to set flutter lint rules as an error and prevent application to build

My goal is to implement set of lint rules. Rule which is set in analyzer as an error and therefore in Dart Analysis is evaluated as error has to prevent application to build.

I have implemented lot of lint rules in analysis_options.yaml:

analyzer:
  errors:
    always_use_package_imports: error
    avoid_empty_else: error
...
linter:
  rules:
    always_use_package_imports: true
    avoid_empty_else: true
...

Everytime one of these rule is not followed, Dart Analysis correctly shows it as an error. Once a new build is triggered it successfully builds. In this particular case my intention is to prevent ios or android from successful build.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I have tried to add this app/build.gradle file, but it didn’t work.

android {
    lintOptions {
        abortOnError true
    }
}

Is there any other approach how to resolve this issue for Android or iOS?

>Solution :

You could execute flutter analyze --no-fatal-infos --no-fatal-warnings in your CI before your build, it should stop before building if there are errors in your code.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading