1

A new error has recently appeared in Android Studio for widget_test.dart:

enter image description here

I am using the most up-to-date flutter version. 'flutter upgrade' provides the following info:

Flutter is already up to date on channel stable
Flutter 3.0.3 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 676cefaaff (5 days ago) • 2022-06-22 11:34:49 -0700
Engine • revision ffe7b86a1e
Tools • Dart 2.17.5 • DevTools 2.12.2

I tried 'flutter pub get', 'flutter upgrade', restarting Android Studio, rebooting PC. I tried adding "test:" into dev dependencies in pubspec.yaml as per this question-answer. Nothing fixed the issue. It continues to persist. However, I can run my app and see it workable in emulator.

Any ideas how to fix this anoying error?

1 Answer 1

1

Solved. As almost always, human factor.. :)

  1. I checked that I do have this library in the directory where Flutter is installed. -> So logically that the linkage is broken.

  2. I created a new Flutter project. -> there was no such error.

  3. I searched in the 'new project' directory for "flutter_test" -> Such query was found in Dart_Packages.xml file. (obviously, I was not able to find "flutter_test" in my main project directory)

  4. I understood that I need to add manually URI to flutter_test package, as it seems something is broken.

  5. I opened ".packages" file in the project's root directory (don't ask why I opened it and not Dart_Packages.xml - I don't know :)) and added the following line: flutter_test:file:///C:/Src/flutter/packages/flutter_test/lib/

    then "flutter clean" and "flutter pub get" commands -> checked ".packages" file and my line dissappeared from there. -> so it seems "pub get" command breaks something. As "pub get" depends on pubspec.yaml, I compared pubspec.yaml files of two projects -> and surprisingly found this:

dev_dependencie                             тs:
  flutter_test:
    sdk: flutter

with NO error highlighted!

Just in case you don't see it at first sight, as I did :), there shall not be so many spaces and cyrillic letter "т" in 'dependencies' word. :)

Long story short: check whether everything is fine with appropriate part of pubspec.yaml. :)

Sign up to request clarification or add additional context in comments.

1 Comment

I don't understand, what is this Yaml snippet means? Are we supposed to paste like thatdev_dependencie тs: ? Or you didn't have time to edit and fix that snippet?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.