Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not pretty priting if using dio to decode #65

Closed
itsJoKr opened this issue Mar 10, 2023 · 2 comments
Closed

Not pretty priting if using dio to decode #65

itsJoKr opened this issue Mar 10, 2023 · 2 comments

Comments

@itsJoKr
Copy link
Contributor

itsJoKr commented Mar 10, 2023

When using

    final response = await _dio.get<List<dynamic>>(
      ApiEndpoints.tournaments,
    );

it would not print nice but all will be printed in one line.

Reason:
In the case dio is decoding json, the dio_logger will get string like [{id: 1}, {id: 2}]. Note the missing "" from json. And it would crash with FormatException on line 129 and go in catch clause:

    try {
      final Object object = const JsonDecoder().convert(data.toString());
      const JsonEncoder json = JsonEncoder.withIndent('  ');
      value = '║  ${json.convert(object).replaceAll('\n', '\n║  ')}';
    } catch (e) {
      value = '║  ${data.toString().replaceAll('\n', '\n║  ')}';
    }

Workaround is to always get the string and decode it by yourself:

    final response = await _dio.get<String>(
      ApiEndpoints.tournaments,
    );
@lucavenir
Copy link

Workaround is to always get the string and decode it by yourself

Which defies the purpose of using dio in the first place, just to address this issue.
Is there any chance this can be addressed or is there any other workaround?

@zenled
Copy link
Contributor

zenled commented Mar 14, 2024

Closing, this has been improved in the late release of the flutter_loggy_dio package.

@zenled zenled closed this as completed Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants