The warnings correctly indicate there is a problem.
The correct solution depends on if the Dart files are conceptually separate from each other or are related.
If they are conceptually separate, then they should be defined as belong to different libraries with different library names.
import command is used to reference a compilation unit from a different library, not a compilation unit that belongs to the same library. It expects every library to have a unique library name.
If a Dart file is treated as a library (i.e. is the subject of an
import statement) and is not explicitly named then its implicit name is the empty string. In this case, both files are treated as libraries, and it is complaining about there being two libraries with the same name (of an empty string).
For this to work as separate libraries, given them different names:
Part of the same library
But if they related they should not be referenced as libraries. That is, do not use the import command. Use the
part command, which treats the Dart file as compilation unit that belongs to the same library.
part of baz;
part of baz;
Only the top library file can contain the
part statements. You do not need (and cannot have)
part statements inside the other files, even if they reference definitions from each other. If there are multiple files, just list them all in the top library file (in any order).
Although the implicit name for a library is the empty string, there is no way to use that when there are multiple parts involved: so even if these files are never going to be imported as a library, you will still need to explicitly assign it a library name.
part statements are very different from the
#include macro in the C preprocessor.