I tried many things, and the last one worked for me;
dart pub global activate flutterfire_cli
I concluded that this error is related to Flutterfire, and the actions related to it solved the problem.
https://firebase.flutter.dev/docs/cli/