analyzer library
Static analysis of a Flutter project's widget trees.
FlutterProjectAnalyzer resolves every library under lib/ with
package:analyzer and turns what each widget's build returns into a
tree of DartValues: constructor calls, literals, references and calls.
It never runs the app.
final analysis = await FlutterProjectAnalyzer('path/to/app').analyze();
for (final screen in analysis.screens) {
print('${screen.name} (${screen.source})');
}
The project must be resolved first (flutter pub get).
Classes
- AccessValue
-
Instance property read:
textTheme.bodyLarge,color.shade200. - BinaryValue
-
Arithmetic that can't be folded statically, e.g.
MediaQuery.of(context).size.height * .4: the compiler evaluates it once it knows more (like the screen size). - CallValue
-
Method call:
Theme.of(context),style.copyWith(...),buildHeader(). - ConditionalValue
-
cond ? a : b, or a collectionif. otherwise is null for anifwithoutelse. - DartValue
- FlutterProjectAnalyzer
-
Resolves every library under
lib/and extracts widget construction trees. - FunctionValue
-
A closure. returns is its result expression when it has a single one
(useful for
itemBuilder-style callbacks). - ListValue
- LiteralValue
-
16,'Hello',true,null. - LoopValue
-
A collection
for: body is produced once per element of a collection only known at runtime. - MapValue
- ObjectValue
-
A constructor call:
Container(...),EdgeInsets.all(16). - ProjectAnalysis
- Result of statically analyzing a Flutter project.
- RefValue
-
A reference such as
Colors.blue,CrossAxisAlignment.start,AppTheme.lightorkPadding. - UnknownValue
- Anything the analyzer can't represent statically.
- WidgetClass
-
A
StatelessWidget/StatefulWidgetsubclass declared in the project.
Functions
-
applyArithmetic(
String operator, Object? a, Object? b) → Object? -
Applies an arithmetic
operatorto two known values: numbers, or strings for+. Null if they can't be combined.