JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jdk1.8.0_281\bin
Please set the JAVA_HOME variable in your environment to match the location of your Java installation.
How to solve this problem??
You need to explicity download and define the jdk version to be used in the code for running the flutter app.
I also faced the similar issue and below solutions works for me:
Install jdk 11 and add path to gradle.properties
file
org.gradle.java.home=C:\\Program Files\\Java\\jdk-11.0.11