Created
May 21, 2023 14:58
-
-
Save Kaival-Patel/04ea1b19108a4c5f1652342602272b81 to your computer and use it in GitHub Desktop.
UserNetworkService
This file contains hidden or 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 '/src/config/dio_config.dart'; | |
| import '/src/models/api_response_model.dart'; | |
| import '/src/models/user_model.dart'; | |
| import '/src/utils/constants/constants.dart'; | |
| class UserNetworkService { | |
| Future<ApiResponse<List<UserModel>>> getListOfUsers() async { | |
| try { | |
| var res = await Api().get(); | |
| var apiRes = ApiResponse<List<UserModel>>.fromListJson( | |
| res.data, (p) => p.map((e) => UserModel.fromJson(e)).toList()); | |
| return apiRes; | |
| } catch (err) { | |
| logger.e(err); | |
| throw Exception(err.toString()); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment