What does a class with a method named ._() mean in Dart/Flutter?

Technology CommunityCategory: FlutterWhat does a class with a method named ._() mean in Dart/Flutter?
VietMX Staff asked 3 years ago
  • In Dart, if the leading character is an underscore, then the function/constructor is private to the library.
  • Class._(); is a named constructor (another example might be the copy constructor on some object in FlutterAnotherClass.copy(...);).
  • The Class._(); isn’t necessary unless you don’t want Class to ever be accidentally instantiated using the implicit default constructor.