admin管理员组

文章数量:1401298

I run the following code:

import 'pages/home_page.dart';
import 'pages/pages.dart';
import 'package:app/setup.dart';
import 'setup.dart';

The last 3 have red error lines, and the error:

Target of URI doesn't exist: 'pages/pages.dart'. // or 'setup.dart' etc.
Try creating the file referenced by the URI, or try using a URI for a file that does exist.

But the import 'pages/home_page.dart'; doesn't have an error line weirdly. See below a screenshot of my lib folder. screenshot of lib folder So why is importing pages/pages.dart and setup.dart not working? I tried using package:app on line 3 of the above code (in the pubspec.yaml it says name: app) as well just to test if this would work but it doesn't.

I have looked online but can only find answers for importing packages, not importing dart files. There are a few questions about dart files but none of them solve my problem. I tried restarting VSCode,and I tried

flutter clean
flutter pub get

but neither worked. The project was working perfectly fine until I decided do split it from main.dart into smaller dart files and folders. Also interestingly, in my main.dart file, I do

import '../setup.dart';
import '../main.dart';

but only the import '../setup.dart' has the error line. Anyone have any ideas? Thanks so much.

本文标签: flutterTarget of URI doesn39t exist (importing dart files) in VSCode WindowsStack Overflow