How to use a custom jsonDecodeCallback with BackgroundTransformer #2340
Replies: 1 comment
-
|
The |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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,
DefaultTransformeris now deprecated, and one is advised to useBackgroundTransformerinstead. ButBackgroundTransformerdoes not accept a customjsonDecodeCallbackfunction. 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 customjsonDecodeCallbackfunction.So, is there a way to achieve the same functionality using the now recommended
BackgroundTransformerinstead of the deprecatedDefaultTransformer?Beta Was this translation helpful? Give feedback.
All reactions