Does the class name underscore the correct way to ensure that the class is not used outside the library?

If I have a helper class defined in a library that I don't want to use outside the library, is the correct hiding mechanism for placing underscores in front of the class name?

part of foo;

class Bar { } // made available to users of the foo library

class _BarHelp { } // hidden from users of the foo library

Or is there an alternative way to hide BarHelp?

+4
source share
2 answers

Yes, underscores work for class names in the same way that functions, methods, and fields make them available to the library.

+1
source

. , Google Dart.
( ).

0

Source: https://habr.com/ru/post/1619953/


All Articles