I was using VS Code.
What worked for me was clicking on the option it recommends that seems dumb at first time: create file 'file_name.dart'
It merged an initialized file with the one that had in that location. I deleted the unnecessary stuff that is generated, and it was good to go.
I tried everything else I found on many pages over the internet. Diverse kinds of commands. Reopening, changing locations. Reinstalled the plugins.
EDIT 1: False alarm, it is temporary. But still, the quickest method, especially if you use CTRL + Z after it merged. I can't fix it OMG
EDIT 2: I opened now on Android Studio, and it said the file was in the wrong encoding. I changed the encoding (it has a button to select another one), and the errors disappeared!! (at least until now)