Flutter Ubuntu Android Studio->找不到URI目标不存在

标签 flutter android-studio ubuntu

文件内声明的 const 值:

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
]
我通过以下方式使用这个常量:
enter image description here
错误 :
URI 的目标不存在:'package:flutter_complete_guide/dummy_categories.dart'。 (文档)尝试创建由 URI 引用的文件,或尝试对确实存在的文件使用 URI。
结构 :
enter image description here
flutter 医生
医生摘要(要查看所有详细信息,请运行 flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.6, on Linux, locale uk_UA.UTF-8)
[✓] Android 工具链 - 为 Android 设备开发(Android SDK 版本 30.0.3)
[✓] Chrome - 为网络开发
[✓] Linux 工具链 - 为 Linux 桌面开发
[✓] 安卓工作室
[✓] 连接设备(2 个可用)
• 未发现任何问题!
安卓工作室 4.2

最佳答案

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

package:flutter_complete_guide/models/dummy_categories.dart'. 
这是一个例子:
  • 进口声明

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


  • 结构:

  • enter image description here

    关于Flutter Ubuntu Android Studio->找不到URI目标不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67517512/

    相关文章:

    flutter - 如何使用动态参数名称调用实例方法?

    android - 有没有办法检测应用程序是否通过后退按钮关闭?

    java - 如何在 android studio 发布版本中修复 "There is no public dispose() method in the class d.g.b$a"

    c++ - 在 Ubuntu 上使用 GLFW 设置 OpenGL NetBeans 项目

    flutter - 抛出了另一个异常 : 'package:flutter/src/widgets/navigator.dart' : Failed assertion: line 3803 pos 12: '_history.isNotEmpty' : is not true

    flutter - 等待另一个flutter命令释放启动锁

    android-studio - Android Nougat要求IDE必须与Java 1.8或更高版本一起运行。

    android - 找不到与给定名称匹配的资源(在 'theme' 处,值为 '@style/AppTheme.AppBarOverlay' )

    macos - Cron 作业未执行具有命令以作为另一个用户执行的 Shell 脚本

    C 中用于 SSHD 的自定义 PAM