In my case, the error occurred due to the use of outdated Flutter plugins, specifically ones that rely on the old Android embedding (v1). Modern Flutter projects — especially those created using recent versions of Android Studio — are configured to use Android embedding v2, which is incompatible with v1-style plugins.
run this command:
flutter pub upgrade
If upgrading doesn't resolve the issue, check the plugin’s page on pub.dev. If the plugin is:
After upgrading or replacing the plugins, run the following commands:
flutter clean
flutter pub get