Package import - Target of URI does not exists

29.2k views Asked by At

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!

10

There are 10 answers

1
Alexander Doroshko On

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

0
Ivan Yoed On

It seems that dart:mirrors library is no more supported. See here:

https://github.com/flutter/flutter/issues/1150

0
Serge Breusov On

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-

0
Sisekelo Dlamini On

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
0
Hyung Tae Carapeto Figur On

I was using VS Code. What worked for me was clicking on the option it recommends that seems dumb at first time: create file 'file_name.dart' It merged an initialized file with the one that had in that location. I deleted the unnecessary stuff that is generated, and it was good to go.

I tried everything else I found on many pages over the internet. Diverse kinds of commands. Reopening, changing locations. Reinstalled the plugins.

EDIT 1: False alarm, it is temporary. But still, the quickest method, especially if you use CTRL + Z after it merged. I can't fix it OMG

EDIT 2: I opened now on Android Studio, and it said the file was in the wrong encoding. I changed the encoding (it has a button to select another one), and the errors disappeared!! (at least until now)

0
Ajil O. On

If you are using Android Studio do like this:

enter image description here

  • 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

2
Anthony Liriano On

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.

0
Mehmet D. On

Had the same problem while using Visual Studio Code. Had to close and re-open the VS Code but it didn't work out for me. But opening the file by typing code . to the command line solved my issue.

0
Danvari On

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.

0
saigopi.me On

Just Close project and VSCODE it will work