Our great sponsors
-
api_utils
Discontinued A collection of helper functions and an ApiResponse class that make working with REST apis a bit easier.
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
qiscus-chat-sdk-flutter
Qiscus provide everything you need to power up your app with chats. And it's now made simple.
This library just ended up doing the same thing that I've done. There's code duplication in get and post functions, for example. They both call _makeRequest and then _handleResult and have wrapped the whole operation in try catch. I just have an added layer of having multiple clients and to keep trying until I get a good response or I run out of tries. What I want to achieve is to extract the common code of get and post to another function so there would be no duplication.
The node.client is a http client. Both the get and delete functions are identical except for the fact that they invoke different functions of the client. Can I somehow create a private function that contains all the common functionality but also accepts, in addition to other parameters, a function of the client that is to be used? If there exists a way to share the repeating code of all the methods here that would be amazing.
This is the abstract class: https://github.com/qiscus/qiscus-chat-sdk-flutter/blob/master/lib/src/core/api_request.dart#L5 This is an implementation of that class: https://github.com/qiscus/qiscus-chat-sdk-flutter/blob/master/lib/src/user/user_api_request.dart#L3