How to use a custom jsonDecodeCallback with BackgroundTransformer #2340
Unanswered
lars-hl-knowit
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, in our Flutter project, we've set the transformer for our Dio client like this:
dio.transformer = DefaultTransformer( jsonDecodeCallback: (body) { final transformedBody = _convertLongIntsToString(body); return json.decode(transformedBody); }, );
After updating the Flutter Dio package,
DefaultTransformer
is now deprecated, and one is advised to useBackgroundTransformer
instead. ButBackgroundTransformer
does not accept a customjsonDecodeCallback
function. We need this, because the data our app interacts with uses numbers for IDs which are so long that when the app is built for Web, and converted to java script, these IDs are misrepresented. So we convert them to strings with our customjsonDecodeCallback
function.So, is there a way to achieve the same functionality using the now recommended
BackgroundTransformer
instead of the deprecatedDefaultTransformer
?Beta Was this translation helpful? Give feedback.
All reactions