Having recently experienced this swapping main.dart files in Android Studio (Ladybug), I gratefully concur with ketan-ramteke and salihgueler . The only difference for me was that there was no Flutter-iconed main.dart. So, I created it, entering 'Edit Configurations...', and under Flutter, clicking the '+', completing the Name and Data entrypoint fields with name of location of the newly-minted main.dart, clicking Apply and OK. Then my new main.dart properly appeared, Flutter-iconized, from the configurations menu to be run as Flutter, in lieu of the Dart config it had been. No more errors.