Android Studio: errors in Dart are not showing on the screen
Asked Answered
S

5

27

I created a new project in Android Studio Bumble Bee. However when I enter some code that has errors in it the error is not showing up.

For example if I enter the following:

import './screens/authorization/auth_root_screen.dart';

When this directory or screen doesn't exist no error is shown.

Or even if I enter some code with a typo...

iiiiiiiiiiiiiiiiiiiiimport './screens/authorization/auth_root_screen.dart';

No error is shown in the IDE.

I guess I am missing a setting somewhere but I havent been able to find it. This always worked fine before I installed BumbleBee.

Any help would be gratefully received.

Thanks so much.

Slim answered 22/2, 2022 at 8:8 Comment(0)
S
131

Hi thanks for looking at this. I have solved it myself. I'll post the solution here in case anyone has a similar question.

Do the following:

  1. At the bottom of the Android Studio IDE is a tab called: Dart Analysis. Click on it to open the tab.

  2. On the left hand side of the Dart Analysis screen that opens is a settings Icon. Click on this.

  3. On the settings screen, make sure that "Scope Analysis to the Current Package" is ticked on.

Here is a screen print:

enter image description here

Slim answered 22/2, 2022 at 14:51 Comment(5)
What the..? Why would this ever be unticked as a default, let alone ever? One of the more confusingly simple issues I've had.Paleobiology
This works!!! If you are using Android Studio Giraffle and newer, you need to disable new UI in Settings before can seeing Dart Analysis tab. Or open View -> Tool Windows -> Dart Analysis.Wonderment
Much helpful. this worksEutherian
HOLY! this checkmark wasted my 2 days googling its fix. Good I landed here and found the fix, else I was going to reinstall everythingSnorkel
Thanks! I'm wondering why this option isn't enabled by default! :)Piedadpiedmont
R
0

Have you installed the Flutter extension for your Android Studio? You can find it in the Extensions section of your IDE.

Rebak answered 22/2, 2022 at 8:19 Comment(2)
Well it was installed. Ive been using Android Studio for several years. Not sure if somehow it has now been removed. Where is the Extensions section?Slim
Actually I think it is installed as if I click on the Dart Analysis tab at the bottom of the screen I see the errors. I just don't see the errors in the main screen of the IDE.Slim
D
0

In my case, this happened while opening a local sub-package that did not have its own analysis options file.

For a Flutter package, you can add one with the following contents:

include: package:flutter_lints/flutter.yaml
Drennan answered 17/7, 2023 at 13:35 Comment(0)
M
0

I am aware that this issue has been resolved; however, if the solution that worked for the same problem does not resolve your issue, there may be a problem related to the export and import statements used in your project. It is advisable to check your project's exports and imports.

For example, in my scenario, the components in my 'x' package were using the same export file, which is "package:x/_package_exports.dart"; and due to a widget with a constructor named WidgetX.group(), Dart analysis was not showing any errors.

To overcome this issue, starting from the _package_exports.dart file, I tried commenting out each export in this file and its sub-files one by one, and I found that there was an issue with a constructor named .group().

In summary, if you are experiencing the same problem, and Dart analysis is not showing any errors when you refresh it, and you cannot navigate to the files when clicking on export or import lines in the IDE, try commenting out the main exports in your project and refresh Dart analysis. If Dart analysis starts working correctly after commenting out an export, there may be an issue in either the exported file or the files it exports.

Metaplasia answered 22/12, 2023 at 8:43 Comment(0)
C
-1

Come do these things

First, run this Flutter Doctor code in the terminal, be sure to check all the options

Specify the second SDK FLutter for Android Studio

Third, install the Dart and Flutter plugins

Colettecoleus answered 22/2, 2022 at 10:4 Comment(1)
Yes these have already been checked. The issue isn't with Dart or Flutter. It is with only that Android Studio is not showing code errors in the main screen.Slim

© 2022 - 2024 — McMap. All rights reserved.