Mike
Mike

Reputation: 2705

Flutter Ubuntu Android Studio -> can't find Target of URI doesn't exist

Const values declared inside the file:

import 'package:flutter/material.dart';
import 'package:flutter_complete_guide/models/category.dart';
import 'package:flutter_complete_guide/models/meal.dart';

const kDummyMeals = <Meal>[
   Meal(
    id: 'm1',
    categories: [
      'c1',
      'c2',
    ],
    title: 'Spaghetti with Tomato Sauce',
    affordability: Affordability.Affordable,
    complexity: Complexity.Simple,
    imageUrl:
        'https://upload.wikimedia.org/wikipedia/commons/thumb/2/20/Spaghetti_Bolognese_mit_Parmesan_oder_Grana_Padano.jpg/800px-Spaghetti_Bolognese_mit_Parmesan_oder_Grana_Padano.jpg',
    duration: 20,
    ingredients: [
      '4 Tomatoes',
      '1 Tablespoon of Olive Oil',
      '1 Onion',
      '250g Spaghetti',
      'Spices',
      'Cheese (optional)'
    ],
    steps: [
      'Cut the tomatoes and the onion into small pieces.',
      'Boil some water - add salt to it once it boils.',
      'Put the spaghetti into the boiling water - they should be done in about 10 to 12 minutes.',
      'In the meantime, heaten up some olive oil and add the cut onion.',
      'After 2 minutes, add the tomato pieces, salt, pepper and your other spices.',
      'The sauce will be done once the spaghetti are.',
      'Feel free to add some cheese on top of the finished dish.'
    ],
    isGlutenFree: false,
    isVegan: true,
    isVegetarian: true,
    isLactoseFree: true,
  ),
// some other values

]

I use this const via: enter image description here

Error: Target of URI doesn't exist: 'package:flutter_complete_guide/dummy_categories.dart'. (Documentation) Try creating the file referenced by the URI, or Try using a URI for a file that does exist.

Structure:

enter image description here

flutter doctor Doctor summary (to see all details, run flutter doctor -v):

[✓] Flutter (Channel stable, 2.0.6, on Linux, locale uk_UA.UTF-8)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)

[✓] Chrome - develop for the web

[✓] Linux toolchain - develop for Linux desktop

[✓] Android Studio [✓] Connected device (2 available)

• No issues found!

Android Studio 4.2

Upvotes: 1

Views: 270

Answers (3)

petchgabriel
petchgabriel

Reputation: 198

I experienced on this problem too. I create a file on Windows machine. Then I got this error too.

I resolved by deleted that file and create a new file that has difference file name on Mac machine then everything get back to work.

Upvotes: 0

Yashawant
Yashawant

Reputation: 1150

I think you should use your own project name to import the files within your project. You should replace import 'package:flutter_complete_guide/... to import 'package:meals/...

you can also use relative path to import files like import '../dummy_categories.dart';

if you want to import from some unpublished package you can add it in your pubspec.yaml like this

Upvotes: 0

Thierry P. Oliveira
Thierry P. Oliveira

Reputation: 626

Do you can change your import using the full path. The difference is the "models" folder, like this:

package:flutter_complete_guide/models/dummy_categories.dart'. 

This is an exemple:

  • Import statement

import 'package:todo_app/app/global/colors.dart';

  • Structure:

enter image description here

Upvotes: 1

Related Questions