Package import - Target of URI does not exists

2019-06-18 05:02发布

问题:

Please check my project:

https://github.com/MaximGo/WebTech_Projekt.git

In the file 'tetrisclient.dart' I want to import the generated package from the lib-folder.

import 'package:tetris/tetris.dart';

But I get the Erro 'Target of URI does not exists'

Thanks for your help!

回答1:

I know this is an old question, but I came across it and resolved it. But anyone that runs into this, simply close your project and reopen it. That solved it for me. I'm using Android Studio.



回答2:

I had the same problem when using Visual Code and following the Write your first app tutorial. This issue was resolved by just closing and reopening the project.



回答3:

If you are using Android Studio do like this:

  • Click on Dart Analysis on the bottom
  • Click on the Restart Dart Analysis Server icon on the left side of the window.

The errors will be fixed



回答4:

Run pub get. If you use WebStorm you can do it using corresponding action from the pubspec.yaml file context menu.



回答5:

Solution: restart Android Studio. Or: just close and reopen project.

Had similar problem. For anyone who want to investigate, here my steps. I decided to try that library https://pub.dartlang.org/packages/path_provider

I added dependency and download package via Android Studio. I also see path_provider.dart in External Libraries in my project. So, the file exist! But Studio show me an error "Target of URI doesn't exist" - how to fix it?

    import 'package:path_provider/path_provider.dart';

I use example code from path_provider project: https://pub.dartlang.org/packages/path_provider#-example-tab-



回答6:

If you are copying code from codelabs by Google. You need to take care of remember spaces.

E.g. in pubspec.yaml

this:

flutter:
  sdk: flutter

  cupertino_icons: ^0.1.0
  english_words: ^3.1.0   # add this line

is not this:

flutter:
  sdk: flutter

  cupertino_icons: ^0.1.0
  english_words: ^3.1.0   # add this line


标签: dart dart-pub