Entrypoint doesn't contain a main function on the flutter - flutter

How can fix the error and run the my code

I don't see in your files tree the main.dart file, I assume that you deleted it, Dart/Flutter project running starts from there, exactly from it's main() method.
You just need to undo the deletion of that file, or creating a new one under the /lib directory

Related

Unverified breakpoint in VSCode in Flutter

My debug mode does not work as I see the unverified breakpoint notice in VSCode in debug mode.
I already checked the Launch json file and it is fine, but something else is wrong which I do not see what it is. Maybe something related to paths, etc.
I tried to make a new project in VSCode using the command and the new default Flutter project is OK.
So it seems like, if I can make a fresh project from my current project then my problem could be solved. But how? I tried to move my files from my current project to the newly made Default Flutter project but I do not think this is the way. Because I guess some of the files in my project are the source of issues...
I already deleted .vs file but no help.
Do you have any good idea how to fix this issue?
First try cleaning the project files using flutter clean then flutter pub get, try running the app without debugging and if you are down for making a new one just move the lib and assets folders and copy the content of pubspec.yaml file.

Weird output from "flutter clean" command when used outside folder that has build

When i run flutter clean a folder outside the main build folder. I this response:
Changing current working directory to: /User/..
Why is that? and what does working directory refer to? How do i know my old one?
There needs to be a yaml file for flutter clean to work correctly.
That was my mistake.

Why does the flutter folder have an error

So i have this problem where in the flutter folder having some error but it does not affect on my project. its just that it slows down the vscode and might cause future error in my future projects.
Your main function should be in the file main.dart under the top level lib directory.
An error doesn't affect your application because it seems like this file is not used in your main project.
import 'package:test/test.dart'; doesn't exist which means you might be not added in pubsec.yml file or didn't sync it properly(put get).
https://pub.dev/packages/test go here to check how to implement and use it or if you don't need it for now just remove it or comment it.

Flutter Package URI doesn't exist inside package's test

Inside the Flutter project directory, I created a package with the following command :
flutter create --template=package emoji_support
After it completes creating the package and completes flutter get.
But..
Files inisde package's /test directory can't find files inside package's /lib directory :
import 'package:flutter_test/flutter_test.dart'; is resolved ✅
But...
import 'package:emoji_support/emoji_support.dart'; is not resolved ❌
File structure
What error am I making here?
I created a package inside my project flutter_example_file_picker with flutter create --template=package emoji_support
Then in the pubspec.yaml of the project (not the one inside the plugin) flutter_example_file_picker > pubspec.yaml I added to the dependenceis the package
dependencies:
flutter:
sdk: flutter
emoji_support:
path: ./emoji_support
and the problem resolved, I could run the test with no problem, also tried with a relative path without adding it to the dependencies and worked too
UPDATE
I think I undestand how to fix it without adding it to the pubspec, when creating a plugin inside a project, the flutter plugin of AndroidStudio (or VS) is still working in the main route (check the terminal dir and it will be C:/.../Workspace_Android\hundreddaysofflutter> so it doesnt detect the inner plugin) and doesn't update to detect the new folder. Even if it's red and says it cannot detect the URI.
You can ignore it and try to run the test and see if it detects the inner dart_tool with package_config.json, then it will run succesfully and the problem will dissapear. The second option is to move to the folder where the plugin is (in the terminal cd my_plugin_name_folder or just file open and open the plugin).
Run flutter get pub (it does it automatically when creting the first time a project but sometimes when you create one inside another it doesnt do it) to run for the first time the package and create the package_config.json inside dart_tool (the dart_tool of the plugin), at the end of the file you can see the name and rootUri of the package, now you can use it in your test nad it should detect it correctly. Sometimes it's generated but it seems it doesn't update correctly and the IDE doesn't know even if it's there.
This is just a problem that occurs , when you are adding new sub_directories in vsCode.
just a simple exist and re-open will fix the issue.
tell me if that fix it.

How to develop Flutter app and related package at same time in VS Code

I have a Flutter app and a package folder loaded in VS code at the same time within a workspace. What entry do I need to make to my app's pubspec.yaml file to ensure that changes I've made to the package are compiled and included whenever I hot reload or restart the app? What would be an alternate strategy if this is not possible?
If your pubspec.yaml refers to your package with a path then I would expect this to happen automatically. If not, I would consider it a bug. Please file an issue at https://github.com/Dart-Code/Dart-Code and include a log file generated by running the Dart: Capture Logs command and as much info about your project layout as possible (a clonable repo to repro would be perfect).