Created
March 21, 2022 06:45
-
-
Save dev4jam/b059d010716b63f610c609b1d4dc0ee8 to your computer and use it in GitHub Desktop.
Network response
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
import 'package:freezed_annotation/freezed_annotation.dart'; | |
part 'NetworkResponse.freezed.dart'; | |
@freezed | |
class NetworkResponse<Model> with _$NetworkResponse { | |
const factory NetworkResponse.ok(Model data) = Ok; | |
const factory NetworkResponse.invalidParameters(String message) = InvalidParameters; | |
const factory NetworkResponse.noAuth(String message) = NoAuth; //401 | |
const factory NetworkResponse.noAccess(String message) = NoAccess; //403 | |
const factory NetworkResponse.badRequest(String message) = BadRequest; //400 | |
const factory NetworkResponse.notFound(String message) = NotFound; //404 | |
const factory NetworkResponse.conflict(String message) = Conflict; //409 | |
const factory NetworkResponse.noData(String message) = NoData; //500 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment