Skip to content

Instantly share code, notes, and snippets.

@pasindud
Created June 13, 2021 11:41
Show Gist options
  • Save pasindud/e7fab65f0126c5706a7e9364a4653e47 to your computer and use it in GitHub Desktop.
Save pasindud/e7fab65f0126c5706a7e9364a4653e47 to your computer and use it in GitHub Desktop.
class ClassName {
factory ClassName(Object complicatedObject) => ClassName.internal(
complicatedObject,
// Creation of this object is handled in the constructor
Object(),
);
@visibleForTesting
ClassName.internal(
this._complicatedObject,
this._complicatedObject2,
);
// Never every directly create a new object here
// All objects should be set from
// ClassName.internal()
final Object _complicatedObject;
final Object _complicatedObject2;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment