Gautam Mundada
Gautam Mundada

Reputation: 53

I am getting red lines under my flutter code but the code is perfectly functioning and there is no error

As you can see on the top right side, there is a green tick meaning the code is working and the app I built using this functioning perfectly and as expected. Need help getting ride of those red underlines.

https://i.sstatic.net/jJvvJ.png

Update 1:Output of flutter doctor -v Update 2:Output of debug on app

Upvotes: 5

Views: 8608

Answers (7)

Yunus Kocatas
Yunus Kocatas

Reputation: 316

The issue is your Fadeanimation file make it fadeanimation the capital word is effect your code.

Upvotes: 0

Nur Haslina
Nur Haslina

Reputation: 203

After weeks try to figure out the problem and try all the suggestions (not working in my case), I noticed that my project's Flutter SDK path is empty. After I enter the correct path, all the red line disappear instantly!

Steps:

  1. Go to File | Settings | Languages & Frameworks | Flutter.

  2. Flutter SDK path: C:\src\flutter (in my case)

  3. Click Apply

  4. Click OK

Upvotes: 0

Ujjawal Maurya
Ujjawal Maurya

Reputation: 616

If you are using VS Code, sometimes restarting your analyzer solves your problem. sometimes flutter clean and then flutter pub get solves. in my case, both are not working. This issue is having with only one project, are projects are still working fine. I think Reinstallng Android Studio and Flutter sdk will solve this

Upvotes: 1

Shrip
Shrip

Reputation: 181

flutter doctor
flutter clean 
flutter pub get

after entering these commands flutter code doesn't compile.

I tried flutter upgrade and now problem got solved.

Upvotes: 1

Noboru82
Noboru82

Reputation: 36

I had the same issue, it was very frustrating but was able to solve it.

What worked for me was restoring my Android Studio setting to the default settings by removing the entire ".AndroidStudio4.0" (or whatever version you are using) folder that is usually located in C:\Users\[user name]\.

Then you open Android Studio, select NOT to import any settings, install the Dart and Flutter plugins, and that's it.

It should take about 2 minutes.

Upvotes: 2

Milvintsiss
Milvintsiss

Reputation: 1448

Look at your first import, it should be something like this:

'package:YOURAPPNAME/FadeAnimation.dart'

Also, try to invalidate android studio cache and restart (in file menu)

Upvotes: 0

Alex Jean
Alex Jean

Reputation: 682

Welcome to stack overflow. Looks like a standard package import error.

See link here. https://flutter.dev/docs/development/packages-and-plugins/using-packages

I suggest you try in terminal running three commands

flutter doctor
flutter clean 
flutter pub get

If you see errors at any of these commands, act accordingly.

If no error, I suggest check the contents of your .packages file and pubspec.lock that they list all the dependencies you want to import including Flutter and Dart.

Upvotes: 1

Related Questions