Even I have the file in lib/ folder flutter gives me error
Here is my file
C:\SRC\flutter\packages\flutter_tools>flutter run
Target file "lib\main.dart" not found.
Edit:
here is my configuration
I have looked to this topic
Getting error like "Target file "lib\main.dart" not found." whlie building APK in flutter
But this situation is different from mine.
Reason:
This is the error because of the main execution starts searching main file, but can't find it.
Solution:
Go to Edit Configurations...
Set here main.dart file as dart entry point here and save it...
Another Solution
Run following command
flutter run -t lib/main.dart
Related
When I tried to run Flutter app on windows, it gives an error then says Exited Sigterm. or stmh like this.
the error says;
Re-run cmake with a different source directory
cmake files does not match...
etc.
The Steps that helped me to handle this error are;
open your terminal then write following commands
flutter clean
flutter pub get
flutter run
This will remove you build file and re-create it.
Your problem should have solved now.
After creating my app on flutter, I tried to create an app file from it ..
But I keep getting an error which says "flutter.bat failed to run. System cannot find the path specified at line1 char1"
I don't know if there's a solution to that.enter image description here
run flutter doctor -v and discard what it produces.
And try to fix your project, for this call
flutter create project_name for the folder where the root project is located.
I have added all the path environment variables and the flutter doctor command does not give any errors. However, when I try to run the command Flutter Run inside my project, I get the following error:
I have added all the path variables correctly. I get the same error if I try to run this project from within Android Studio.
It turns out that my project was nested very deeply. SO it's better to keep you project outside. It's works after that.
When running flutter create followed by project name, I receive this error:
Error: Error when reading '../documents/flutter/bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot': No such file or directory
Running "flutter pub get" in pics...
pub get failed (254; Error: Error when reading
'../documents/flutter/bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot': No
such file or directory)
I'm trying to create a new flutter project in xcode. How would I fix this?
'../documents/flutter/bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot': No
such file or directory
It seems like there may be files missing from your Flutter SDK. There should be a file in the Flutter SDK at bin/cache/dart-sdk/bin/snapshots/pub.dart.snapshot but this error suggests it's missing.
The easiest fix may be to delete the bin/cache folder which will cause Flutter to re-download the Dart SDK and other components when you next run flutter. This may take a little while depending on your connection, but is the simplest way to ensure the cache folder is complete. I would suggest closing all IDEs/editors when doing this.
I have same issue but the problem was windows defender at real time detection so the solution was to switch off it then create a project...
C:\flutter\flutter_windows_v1.9.1+hotfix.2-stable\flutter\bin\flutter.bat --no-color build apk
Target file "lib\main.dart" not found.
Process finished with exit code 1
You can set an entry point like this:
flutter run --target=lib/Login.dart
flutter build apk --target=lib/Login.dart
This article shows you how to set up IDE (VSCode/AS) to build another target file.
I don't think you should be changing the entry file, you can always use the main.dart without issues and then set the Entry class there. This doesn't stop your app from working.