Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude a file from analyzing by Android Studio for a Flutter project?

I am using Android Studio for my Flutter program, and I want to include a dart file like what the Flutter Gallery app does, such that I use it as an asset instead of it being part of my program. How can I do that? A workaround is to use a file extension like 'txt' instead of 'dart', but that is not great.

I tried marking the file as plain text by right-clicking on the file, that does not help. I can bear the error warnings, but Android Studio does not allow me to reload the program if that file cannot be compiled (shown below).

enter image description here

like image 787
Herman Avatar asked Aug 19 '18 01:08

Herman


1 Answers

There is an option for analysis_options.yaml

analyzer:
  exclude:
    - "path/to/the/file/to/exclude.dart"
    - "or/pattern/**/*.dart

but it's not fully working yet.

See https://github.com/dart-lang/sdk/issues/34053
https://github.com/dart-lang/sdk/issues/25551
for more details.

like image 194
Günter Zöchbauer Avatar answered Nov 15 '22 07:11

Günter Zöchbauer