By any chance if you would have made changes to your pubspec.yaml file , there are high chance that you will get this error Error: Member not found: 'packageRoot' in Flutter
if not upgraded. So the working solution for the problem is as below
flutter upgrade
flutter pub upgrade
if you see any other solution is working , feel free to update in the comments so that it will be helpful for others