I also faced similar problem after updating Android Studio to Ladybug. My Flutter project was in working condition but after updating Android Studio, started getting this error. After browsing through many answers, below steps solved the issue:
Open the android folder in the flutter project folder into Android Studio and update the Gradle and Android Gradle Plugin to the latest version (You can update using the Update prompt you get when you open the project or manually).
In the android/app/build.gradle file make sure correct JDK version is being used in compileOptions and kotlinOptions blocks.
Make sure the correct Gradle and Android Gradle Plugin versions are used in the build.gradle file.