PeterP
PeterP

Reputation: 251

Package import - Target of URI does not exists

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!

Upvotes: 24

Views: 31043

Answers (10)

Mehmet D.
Mehmet D.

Reputation: 31

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.

Upvotes: 0

Ivan Yoed
Ivan Yoed

Reputation: 4395

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

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

Upvotes: 0

Hyung Tae Carapeto Figur
Hyung Tae Carapeto Figur

Reputation: 1533

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)

Upvotes: 0

saigopi.me
saigopi.me

Reputation: 14908

Just Close project and VSCODE it will work

Upvotes: 1

Ajil O.
Ajil O.

Reputation: 6892

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

Upvotes: 14

Anthony Liriano
Anthony Liriano

Reputation: 599

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.

Upvotes: 16

Sisekelo Dlamini
Sisekelo Dlamini

Reputation: 29

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

Upvotes: 1

Serge Breusov
Serge Breusov

Reputation: 1386

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-

Upvotes: 4

Danvari
Danvari

Reputation: 536

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.

Upvotes: 49

Alexander Doroshko
Alexander Doroshko

Reputation: 1841

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

Upvotes: 3

Related Questions