Fix exception when printing Response

This commit is contained in:
Ming Ming 2022-12-13 23:50:00 +08:00
parent bb7919ff15
commit 8c85f98293
2 changed files with 3 additions and 2 deletions

View file

@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;
import 'package:logging/logging.dart';
import 'package:nc_photos/account.dart';
import 'package:nc_photos/string_extension.dart';
import 'package:to_string/to_string.dart';
import 'package:xml/xml.dart';
@ -25,7 +26,7 @@ class Response {
/// Content of the response body, String if isResponseString == true during
/// request, Uint8List otherwise
@Format(
r"${kDebugMode ? body.toString().replaceAll(RegExp(r'\n\t'), '').substring(0, 200) : '...'}")
r"${kDebugMode ? body.toString().replaceAll(RegExp(r'\n\t'), '').slice(0, 200) : '...'}")
final dynamic body;
}

View file

@ -9,6 +9,6 @@ part of 'api.dart';
extension _$ResponseToString on Response {
String _$toString() {
// ignore: unnecessary_string_interpolations
return "Response {statusCode: $statusCode, headers: ..., body: ${kDebugMode ? body.toString().replaceAll(RegExp(r'\n\t'), '').substring(0, 200) : '...'}}";
return "Response {statusCode: $statusCode, headers: ..., body: ${kDebugMode ? body.toString().replaceAll(RegExp(r'\n\t'), '').slice(0, 200) : '...'}}";
}
}