How I fixed it:
I went to File > Invalidate Caches / Restart and selected Invalidate and Restart.
After that, Android Studio finally recognized the project as a Flutter app.