Hi everyone ,
I’m facing a persistent issue with SonarCloud Flutter analysis where Flutter framework imports are reported as unresolved, even after a full compilation step, as recommended in Sonar documentation.
Problem Description
During SonarCloud analysis, I get errors like:
Target of URI doesn't exist: 'package:flutter/material.dart'
As a result, core Flutter symbols are marked as unresolved:
-
StatefulWidget -
State -
BuildContext -
MaterialApp
However:
-
The project builds successfully
-
flutter analyzepasses locally and in CI -
The issue appears only in SonarCloud
Environment
-
Flutter (stable)
-
SonarCloud
-
CI/CD (Linux-based runner)
-
Flutter project (non-web-only, multi-platform)
What I’m Already Doing (Important)
I’m explicitly following Sonar’s recommendation that Dart analysis requires compilation to generate semantic information
(ref: Sonar community post about Flutter requiring build before analysis).
CI/CD Steps (Simplified)
- flutter --version
- flutter pub get
# Optional code generation
- flutter pub run build_runner build --delete-conflicting-outputs || true
# FULL compilation (multiple fallbacks)
- flutter build web --release --no-pub || \
flutter build apk --debug --no-pub || \
dart compile kernel lib/main.dart -o /dev/null
# Verify Dart context
- test -f .dart_tool/package_config.json
- grep '"name": "flutter"' .dart_tool/package_config.json
# Generate analyzer report
- flutter analyze --machine > flutter_analyze_report.json
# SonarCloud scan
- sonarcloud-scan
Verification Checks
-
.dart_tool/package_config.jsonexists -
Flutter SDK is listed inside package_config.json
-
Compilation artefacts exist under
.dart_tool/ -
Analyser report is successfully generated
Despite all this, Sonar still fails to resolve:
package:flutter/material.dart
Questions
-
Is
flutter build web / apksufficient for SonarDart semantic analysis, or is a specific build target required? -
Does SonarCloud require access to Flutter SDK sources in a specific path or env variable?
-
Is
sonar.dart.analysis.mode=flutterstill required, or deprecated? -
Is this a known limitation/bug with SonarDart in CI environments?