The error is somehow related to the new AndroidStudio update.Checkout this issue: https://github.com/flutter/flutter/issues/156304
To solve the problem checkout this answer: https://stackoverflow.com/a/79095064/7369590