Flutter 颤振Ubuntu Android Studio->;can';找不到URI的目标';不存在

Flutter 颤振Ubuntu Android Studio->;can';找不到URI的目标';不存在,flutter,android-studio,ubuntu,Flutter,Android Studio,Ubuntu,在文件中声明的常量值: 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: [

在文件中声明的常量值:

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
导入“包装:颤振/材料.省道”;
进口“包装:颤振全套指南/型号/类别.省道”;
进口“包装:颤振全套指南/模型/餐点.省道”;
常数Kdummals=[
餐(
id:'m1',
类别:[
“c1”,
“c2”,
],
标题:“番茄酱意大利面”,
负担能力:负担能力。负担得起,
复杂性:复杂性,简单,
图像URL:
'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',
持续时间:20,
成分:[
“4个西红柿”,
“1汤匙橄榄油”,
“1个洋葱”,
“250克意大利面”,
“香料”,
'奶酪(可选)'
],
步骤:[
“把西红柿和洋葱切成小块。”,
“烧开水——煮沸后再加盐。”,
“把意大利面条放在沸水里——大约10到12分钟就能煮好。”,
“同时,加热一些橄榄油,加入切好的洋葱。”,
“2分钟后,加入番茄片、盐、胡椒和其他香料。”,
“意大利面一吃完,酱汁就做好了。”,
“在完成的菜上面随意加些奶酪。”
],
IsGlunfree:错误,
是的,
是素食主义者:是的,
isLactoseFree:是的,
),
//其他一些价值观
]

我通过以下方式使用此常量:

错误: URI的目标不存在:“包:flatter\u complete\u guide/dummy\u categories.dart”。(文档)尝试创建URI引用的文件,或尝试对确实存在的文件使用URI

结构

颤振医生 医生摘要(要查看所有详细信息,请运行flutter Doctor-v):

[✓] 颤振(通道稳定,2.0.6,Linux上,locale uk_UA.UTF-8)

[✓] Android工具链-为Android设备开发(Android SDK版本30.0.3)

[✓] Chrome-为web开发

[✓] Linux工具链-为Linux桌面开发

[✓] 安卓工作室 [✓] 已连接设备(2个可用)

•未发现任何问题


Android Studio 4.2

您是否可以使用完整路径更改导入。不同之处在于“模型”文件夹,如下所示:

package:flutter_complete_guide/models/dummy_categories.dart'. 
这是一个例子:

  • 进口声明
导入“package:todo_app/app/global/colors.dart”

  • 结构:

我认为您应该使用自己的项目名称来导入项目中的文件。 您应该将
import'包装:flatter\u complete\u guide/
…替换为
import'包装:finds/

您还可以使用相对路径导入文件,如
import'../dummy_categories.dart';


如果您想从某个未发布的包导入,可以将其添加到您的
pubspec.yaml

中。我也遇到过这个问题。我在Windows计算机上创建了一个文件。然后我也遇到了这个错误

我通过删除那个文件并在Mac机器上创建一个不同文件名的新文件来解决这个问题,然后一切都恢复正常