xsahil03x / super_enum

Create super-powered dart enums similar to sealed classes in Kotlin
https://pub.dev/packages/super_enum
MIT License
116 stars 13 forks source link

Add factory constructors for derived classes to mimic enums #4

Closed xsahil03x closed 4 years ago

xsahil03x commented 4 years ago

eg :

abstract class LoginResponse {
  // Not necessary when case classes are public, 
  // but I usually put factories and constants on the base class.

  factory LoginResponse.success(authToken) = LoginSuccess;
  static const invalidCredentials = const InvalidLoginCredentials();
  static const noNetwork = const NoNetworkForLogin();
  factory LoginResponse.unexpectedException(Exception exception) = UnexpectedLoginException;
}
xsahil03x commented 4 years ago

@astralstriker would you like to work on this ?

astralstriker commented 4 years ago

Sure @xsahil03x

astralstriker commented 4 years ago

Sorry I am somewhat busy with my office work.

xsahil03x commented 4 years ago

Added in the latest commit.