JAVA_HOME is not set and no 'java' command could be found in your PATH

I tried to run my flutter android project from github repo with emulator, but this error comes up

I had same problem.
to solve the issue, I created a flutter project using idx itself.
there in directory idx gave a folder “.idx” and a file “dev.nix” inside it.
you just also need to create “.idx” folder in your project imported from github and “dev.nix” file inside this folder and copy paste the code of “dev.nix” file.

then run your app, it might crash for the first time, but run it again and it’ll work.