flutterdartanalysis

analysis_options.yaml the included file not found


I have a flutter package that uses effective_dart which is working as expected. (I've explicitly tested this by adding/removing the include and ensure that warnings come and go as expected.)

I have the effective_dart dependency in my pubspec.yaml as follows:

name: sounds
version: 0.9.1

repository: https://github.com/bsutton/sounds
homepage: https://github.com/bsutton/sounds
documentation: https://github.com/bsutton/sounds/wiki
description: Sounds provide a complete api and Widgets for audio playback and recording. Both iOS and Android are supported.
environment: 
  sdk: '>=2.1.0 <3.0.0'
  flutter: '>=1.17.0 <2.0.0'
dependencies: 
  device_info: '>=0.4.2+4 <2.0.0'
  flutter_spinkit: ^4.0.0
  meta: ^1.1.8
  path: ^1.6.4
  path_provider: ^1.6.7
  provider: ^4.1.0
  sounds_common: ^1.0.1
  uuid: ^2.0.4
  flutter: 
    sdk: flutter
dev_dependencies: 
  pedantic: ^1.9.0
  effective_dart: ^1.2.1
  dshell: ^1.0.0
  e2e: ^0.5.0
  lint: ^1.1.1
  pub_semver: ^1.4.4
  flutter_test: 
    sdk: flutter
  flutter_driver: 
    sdk: flutter
flutter: 
  plugin: 
    platforms: 
      android: 
        package: com.bsutton.sounds
        pluginClass: Sounds
      ios: 
        pluginClass: Sounds

The analysis_options.yaml contains:

include: package:effective_dart/analysis_options.yaml

    
analyzer:
  errors:
    todo: ignore
  
  strong-mode:
    implicit-casts: false
    implicit-dynamic: false
    

The problem is that I keep getting a warning about the include not being found. If I make a trivial edit (add a commented out blank line) to the analysis_options.yaml file the error goes away for a while but invariably returns (generally after a restart of the ide).

I'm using vs code but believe I've seen it in android studio (although I can't reproduce it now).

The error:

The include file package:effective_dart/analysis_options.yaml in /home/bsutton/git/sounds/analysis_options.yaml cannot be found.

The problem is having no material impact on my project but its just really annoying to have a warning always showing up.


Solution

  • This seems to be a problem with sub projects (your example folder). See https://github.com/dart-lang/sdk/issues/42910

    You can try to exclude the example in your root analysis_options.yaml:

    analyzer:
      exclude:
        # workaround for https://github.com/dart-lang/sdk/issues/42910
        - 'example/**'
    

    And then add a separate analysis_options.yaml to the example.