I ran into a similar issue with Android Studio 2024.2.1 and fixed it by pointing Flutter to JDK 11 manually. This command solved the problem for me:
flutter config --jdk-dir "C:\Program Files\Java\jdk-11"