For anyone else going mad that you’ve set JAVA_HOME but Flutter is not picking it up and reporting a different version, you need to configure the JDK path in Flutter itself. It may be getting confused with the version that comes with Android Studios. Use:
flutter config --jdk-dir="$JAVA_HOME"