step 1 :
make sure you have correctly installed gradle by locating the zip file inside .grade/dist
or
more simpler way is by running choco install gradle for windows or brew install gradle for mac (choco is package manager for Windows https://chocolatey.org/ )
step 2
in yourFlutterAppDir/android/gradle/wrapper/gradle-wrapper.properties file change the distributionUrl to https://services.gradle.org/distributions/gradle-YOUR_LOCAL_VERSION-all.zip mine is distributionUrl=https://services.gradle.org/distributions/gradle-5.0-all.zip
if you got Cannot lock task history cache (APP_NAME\android.gradle\5.0\taskHistory) as it has already been locked by this process.
you may need to clear the cache by removing the .gradle\caches folder
-For Windows it's under C:\Users\YOUR_USER_NAME.gradle\caches
-For Mac OSX it's ~/.gradle/caches execute the following command: find ~/.gradle -type f -name "*.lock" | while read f; do rm $f; done after clearing the cache , run the app again and be patient
end result 💯