Thanks for replying.
I have looked into the @protected annotation, but what I want is more complex. The protected symbols, which could be classes, functions, const vars, etc., cannot be accessed in other directories. They should only be granted access within the current directory, similar to protected classes in Java.
Currently, the cost of searching the path is cheap. However, I encountered another problem, as shown in the pictures below.
I don't allow importing the protected Dart file that starts with '_' and using the symbols within it. Then, I return the correct position to the analyzer server, which I have verified in the unit test. However, in Visual Studio Code and Android Studio, the positions are not the same.
In Visual Studio Code, the error is import 'self_pkg/_protected.dart', but the error line is shown as line 1 column 35. The correct position should be (2, 35).

In android studio. Only the import error is correct...

What I should do to fix it?
Additionally, besides using the Dart analyzer plugin (which is still an immature solution), are there any other ways for me to achieve this requirement? I hope to have stricter control over symbols to achieve better software maintenance.
I appreciate your assistance once again.