Update the JDK Path You can directly update the JDK path using the flutter config command:
flutter config --jdk-dir /Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
then run
flutter doctor
this work for me