Skip to content

Commit

Permalink
[#9] Wrap the decode to ResponseDecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
nkhanh44 committed Aug 11, 2023
1 parent dcb2c53 commit 7504b5f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lib/api/response_decoder.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:japx/japx.dart';

Map<String, dynamic> decode(Map<String, dynamic> json) {
return Japx.decode(json)['data'];
class ResponseDecoder {
static Map<String, dynamic> decode(Map<String, dynamic> json) {
return Japx.decode(json)['data'];
}
}
2 changes: 1 addition & 1 deletion lib/model/response/login_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class LoginResponse {
});

factory LoginResponse.fromJson(Map<String, dynamic> json) =>
_$LoginResponseFromJson(decode(json));
_$LoginResponseFromJson(ResponseDecoder.decode(json));

LoginModel toLoginModel() => LoginModel(
id: id,
Expand Down

0 comments on commit 7504b5f

Please sign in to comment.