Questions tagged [dart-analyzer]

Dart Analyzer is a package that provides a library that performs static analysis of Dart code. It is useful for tool integration and embedding.

Links

73 questions
3
votes
0 answers

test generated Dart code

Prolog I use source_gen to generate Dart code. I'd like to test the output of my generator (using test package). I looked at the tests of source_gen and used json_serializable_test.dart as a template. I can call generate on my generator and get the…
maiermic
  • 4,764
  • 6
  • 38
  • 77
3
votes
1 answer

Dart analyzer: Get type of initial value of a field

How can I get the type of an initial value expression of a field using Dart's analyzer API? class MyClass { var prop = ; } If initial value expression is for example 'text', I'd like to get String. If it is a function…
maiermic
  • 4,764
  • 6
  • 38
  • 77
3
votes
1 answer

dart: proxy annotation usage

Documentation for the @proxy annotation states: If a class is annotated with @proxy, or it implements any class that is annotated, then the class is considered to implement any interface and any member with regard to static type analysis. As such,…
DomJack
  • 4,098
  • 1
  • 17
  • 32
2
votes
1 answer

In Dart, how do I get from the AST to Elements?

In Dart, how do I get from the AST to Elements? I generate the AST like this: var ast = parseFile(path: "/home/user/myFile.dart", featureSet: FeatureSet.latestLanguageVersion()); I can access the declaration nodes, but I would like get to the…
obe
  • 7,378
  • 5
  • 31
  • 40
2
votes
1 answer

Exclude option doesn't work properly by Dart Analyzer

I am using the Flutter INTL package in my app for internationalization. The package generates a generated folder and I want the analyzer to ignore it. I followed the Exclude code from analysis article however, it seems it doesn't work as two of the…
Hesam
  • 52,260
  • 74
  • 224
  • 365
2
votes
2 answers

Dart Analyzer terminated on flutter clean or flutter run

Whenever I use the command flutter clean or flutter run, the window "The Dart Analyzer has terminated." pops up in VS Code. For flutter run I can specify that the analyzer terminates when it says "Running Gradle task 'assembleDebug'" in the…
PlutoHDDev
  • 540
  • 7
  • 25
2
votes
2 answers

Ensuring that all fields are present in constructor parameter list

Is there a standard Dart-way of making sure that all fields of a class are present in a constructor parameter list? A very simplified example: class Message{ String header; String body; DateTime sentAt; Message(this.header, this.body,…
Magnus
  • 17,157
  • 19
  • 104
  • 189
2
votes
1 answer

Dart Rationale for unnecessary_this lint/style check

When linting dart files, one of the checks that seems relatively standard (and part of the google pedantic style) is unnecessary_this, which favors not using the explicit this keyword unless necessary when the instance variable is shadowed. Coming…
tplusk
  • 899
  • 7
  • 15
2
votes
0 answers

DART pubspec.yml error with html and bootstrap package

I get error with the bootstrap version 3.3.7. When I update bootstrap to 4.0.0, error goes away but I do not want to update as there are lot of breaking changes. Resolving dependencies... Package html has no versions that match >=0.12.2+1 <0.13.0…
2
votes
0 answers

Convert compilationUnit object to json in dart

Is there anyway to convert the compilationUnit object into the json? String src = """ import 'package:flutter/material.dart'; void main() { runApp(new MyApp()); } @Entity() class MyApp extends StatelessWidget { // This widget is the root of your…
Rishab Jain
  • 269
  • 4
  • 16
2
votes
1 answer

Analyzer package - How to recursively search in the results of parseDartFile()

Currently trying to understand 'analyzer' package, because I need to analyze and edit .dart file from another file (maybe it's a terrible idea). I think I understand how to go deep into the childEntities tree. But can't understand how to search in…
user64675
  • 482
  • 7
  • 25
2
votes
2 answers

Symbol with private identifier argument

I want to create a symbol equal to that of a private MethodMirror's simplename. However, Symbol's documentation states the argument of new Symbol must be a valid public identifier. If I try and create a const Symbol('_privateIdentifier') dart editor…
DomJack
  • 4,098
  • 1
  • 17
  • 32
1
vote
0 answers

Writing a custom YAML file to apply Dart fixes

I have a Flutter project with two Dart files. In one of the files, I have a class with a deprecated getter that I want to replace with a new one. To achieve this, I created a .fix.yaml file with the custom fix rule. However, when running dart fix…
1
vote
1 answer

dart enforce subtype in generic type (disallow base type) VS switch(Foo)

Given such classes sealed class Base { /* ... */ } class X extends Base { /* ... */ } class Y extends Base { /* ... */ } class Foo { final T t; const Foo({required this.t}); } Reading the docs it seems impossible to restrict…
Stuck
  • 11,225
  • 11
  • 59
  • 104
1
vote
0 answers

IntelliJ ALT+Enter doesn't show correctly on the first key press

I recently updated IntelliJ to 2021.3 Community Edition and I'm using the latest Dart and Flutter plugins. Whenever I press ALT+Enter to open the context menu (for example if a needed library is not imported), it doesn't show all the expected…
Magnus
  • 17,157
  • 19
  • 104
  • 189