You can solve the error "To use the “java” command-line tool you need to install a JDK. Click “More Info…” to visit the Java Developer Kit download website." on macOS, by installing a version of the JDK.
You do not need to install the official Oracle ones, you can install the AdoptOpenJDK ones by running
brew cask install adoptopenjdk
This will save you a preference panel in System Preference, and you can manage the installation with
Subscribe to a curated newsletter
Receive an email every week with curated content about Dart and Flutter.