Flutter/Dart imports not working by GitHub action

When using SonarCloud for the newly Flutter / Dart support, I get errors like:

  • Target of URI doesn’t exist: ‘package:dio/dio.dart’
  • Undefined class ‘CancelToken’

Here are my GitHub action workflow:

      - name: ₍₍🦋⁾⁾ Get dependencies
        run: flutter pub get

      - name: 🎯🏗️ Run build runner build
        run: dart run build_runner build --delete-conflicting-outputs

      - name: 🤖🔨 Build Android app
        run: flutter build apk --debug --flavor development --dart-define="FLAVOR=development"

      - name: SonarCloud Scan
        uses: SonarSource/sonarcloud-github-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  # Needed to get PR information, if any
          SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

My GitHub action builds my Flutter app just fine and I can run flutter analyze and flutter test just fine, but I do not know why SonarCloud fails?

Thank you
Søren

Hello @sne_envidan,

We’re aware of the problem with GitHub action. Here you can find a temporary workaround and explanation: Dart: support Melos dependency management? - #7 by Margarita_Nedzelska

We will improve the onboarding and will think about how we can improve the Sonar GitHub action. Meanwhile, have a look at the provided workaround and let us know if this fixes your issue.

Best,
Margarita

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.