Last active
June 25, 2020 14:17
-
-
Save denisviana/134e2179de59ddabd738a5db68337546 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Resource<T> { | |
final Status status; | |
final T data; | |
final String message; | |
final Exception error; | |
const Resource({this.data, @required this.status, this.message, this.error}); | |
static Resource<T> loading<T>({T data}) => | |
Resource<T>(data: data, status: Status.loading); | |
static Resource<T> failed<T>({Exception error, T data}) => Resource<T>( | |
error: error, data: data, status: Status.failed); | |
static Resource<T> success<T>({T data}) => | |
Resource<T>(data: data, status: Status.success); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Status{ | |
loading, success, failed | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment