Dart Analyzer is a package that provides a library that performs static analysis of Dart code. It is useful for tool integration and embedding.
Questions tagged [dart-analyzer]
73 questions
1
vote
1 answer
How can I resolve Undefined name 'currency' in Flutter for-in loop?
Background
While following London App Brewery's Bitcoin Ticker project, and I got stuck trying to create DropdownMenuItems via a for-in loop. The warning that the Dart Analysis gave me was Undefined name 'currency'. Here's the code that produced the…

chemturion
- 283
- 2
- 16
1
vote
1 answer
Dart analyzer suddenly gives an non-null value error
I have been using code generating packages for months, today I ran the command "flutter pub run build_runner build" on one of my projects, everything built, then when I ran it again, I got this…

Alexandru Stroescu
- 1,067
- 1
- 9
- 16
1
vote
1 answer
linter rule and null safety
I recently replaced deprecated pedantic package with flutter_linter
and now I have hundreds warnings like this:
Avoid using `forEach` with a function literal.
it's related to avoid_function_literals_in_foreach_calls
it sounds good if you have…

Nagual
- 1,576
- 10
- 17
- 27
1
vote
1 answer
What is the correct way to catch both Error and Exception following `effective dart`?
this code sample
import 'package:flutter_test/flutter_test.dart';
void main() {
const one = 1;
String oneAsString() => one as String;
test('Make sure it fails', () {
var s;
var _e;
try {
s = oneAsString();
} on Error…

Francesco Iapicca
- 2,618
- 5
- 40
- 85
1
vote
1 answer
how to get type of identifier dart-analyzer
I am processing method statements in a class and i want to find type of an identifier in those statements.
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/session.dart';
import…

invariant
- 8,758
- 9
- 47
- 61
1
vote
1 answer
how can I analyze dart code to remove duplicate classes?
this question is about static analysis of dart code.
How can I analyze the dart code or visit the each class within a dart file so I could remove the duplicate class, I know these tools exists but i don't know how exactly implement it
PS:duplicate…

Yadu
- 2,979
- 2
- 12
- 27
1
vote
0 answers
Pass callback Function as Parameter to Widget while keeping Lint Rules "argument_type_not_assignable"
In my widget I pass a function callback as a parameter to the widget:
onTap: onTapRestaurantItemCallback
Out in the screen widget, which contains the widget above, I then execute the function callback:
onTapRestaurantItemCallback: () { // Handling…

Rune Hansen
- 954
- 3
- 16
- 36
1
vote
1 answer
NNBD: Least upper bound of String and Null
Working on a patch for some issues in the Dart Analyzer, I need to understand whether Null itself is considered a nullable type.
Currently, the least upper bound computed by Dart’s type algebra for String and Null is String.
However, in my opinion,…

user3612643
- 5,096
- 7
- 34
- 55
1
vote
0 answers
flutter dart analyzer could not be started
VSCode is giving me this error that my dart analyzer could not be started. Everything was working fine some days ago.I have tried to restart it but to no avail and I cant run my project.Any work around on how to fix this issue?
The log output
Sun…

Norbert
- 6,874
- 14
- 40
- 65
1
vote
1 answer
Dart Analyzer: Find instances of a class or its descendants
I am using the build package to take a .dart file and look for definitions of a certain class or its subclasses. Can ClassElement be used for subclasses too?
I am only expecting a single definition of a specific class to be within one file of the…

Jacob Phillips
- 8,841
- 3
- 51
- 66
1
vote
1 answer
dartanalyzer reports errors on the getting started tutorial
Running dartanalyzer on this snipped found on flutter.io/get-started/codelab yields these errors:
$ dartanalyzer lib/main.dart
Analyzing lib/main.dart...
error • The function 'MyApp' isn't defined at lib/main.dart:3:23 • undefined_function
error…

martins
- 9,669
- 11
- 57
- 85
1
vote
1 answer
how to check if function parameter is optional using anzlyzer package?
how to check if function parameter is optional using anzlyzer package?
For example:
myFunction(param1, {param2});
I would like to know that param1 is required and param2 is optional

Luis Vargas
- 2,466
- 2
- 15
- 32
1
vote
1 answer
Dart overriding unary minus operator
As per Language specs (10.1.1 Operators) I am trying to override some operators.
I get an analyzer error when overriding the 'minus' and 'unary minus' operators - one that I don't get:
'The operator "-" is not defined on class Indentation'
but in…

Peter StJ
- 2,297
- 3
- 21
- 29
1
vote
2 answers
dartanalyzer doesn't give a warning for missing implementation from interface
Currently I'm experimenting and learning the Dart language.
I'm creating an abstract class with two abstract methods called IAnimal like this:
abstract class IAnimal
{
String Walk(int distance);
String Eat(String food);
}
Next I create a Dog…

Luc Wollants
- 880
- 9
- 27
0
votes
0 answers
Can't run the custom analyzer_plugin in local project : "Unrecorded error while starting the plugin."
I struggle at running a sample demo project and plugin for the analyzer_plugin
https://github.com/evaisse/dart_demo_analyzer_plugin
I create sample demo project named "demo_analyzed_project" in (./example/demo_analyzer_plugin)
Which use…

evaisse
- 101
- 1
- 6