xxxxxxxxxx
If you are running flutter project.
In edit configuration, run it as flutter project,which has a flutter icon besides it.
If you are testing a dart file
Check your denpendency tree. Delete all flutter related lib like widgets/material/cupertino.
Simple explaination
In short, you are running a file as dart file, but you have imported flutter dependencies like widgets/material at the same time. Either run it as flutter ,or get rid of flutter dependency and run pure dart.