Steps to reproduce
We're using the package 'dio', received data from a POST API, the string bytes in the response get converted to Map<String, dynamic> object.
Flutter logs an error on the Debug Console: "Bad UTF-8 encoding (U+FFFD; REPLACEMENT CHARACTER) found while decoding string: The Flutter team would greatly appreciate if you could file a bug explaining exactly what you were doing when this happened:
https://github.com/flutter/flutter/issues/new/choose
The source bytes were:
[27, 91, 51, 56, 59, 53, 59, 50, 52, 52, 109, 226, 148, ..."
Expected results
The application should not have exit unexpectedly. The API request is already placed inside a try-catch block, the catch block should have been executed.
Actual results
Flutter Web Exit Unexpectedly
Code sample
Code sample
Future<dynamic> post({
required String endpoint,
required dynamic body,
bool? emailService,
}) async {
String url =
'${(emailService ?? false) ? Constants.serverURLForEmails : Constants.serverURL}$endpoint';
Map<String, String> headers = {
'content-type': 'application/json',
};
logger.i('>>>> POST API START [URL: $url] <<<<');
Rx<dio.Response?> response = Rx(null);
String requestUid = Constants.generateUniqueCodeFromTimestamp();
startOngoingRequest(
uid: requestUid,
url: url,
endpoint: endpoint,
);
try {
response(
await dio.Dio().post(
url,
data: body,
options: dio.Options(
headers: headers,
receiveTimeout: const Duration(minutes: 2),
),
),
);
logger.i('>>>> POST API END <<<<');
Map data = response.value!.data;
// data['statusCode'] = response.value!.statusCode;
endOngoingRequest(uid: requestUid);
return data;
} catch (e) {
logger.f('>>>>>>>>>> POST API ERROR');
logger.f('ApiRequest.post() log: ${response.value!.data}');
logger.f('ApiRequest.post() error: $e');
endOngoingRequest(uid: requestUid);
return {
'statusCode': response.value!.statusCode,
};
}
}
Screenshots or Video
Screenshots / Video demonstration


Logs
Logs
Flutter Doctor output
Doctor output
gunpreetsingh@Gunpreets-MacBook-Air frontend % flutter doctor -v
[✓] Flutter (Channel stable, 3.24.5, on macOS 15.1 24B83 darwin-arm64, locale en-IN)
• Flutter version 3.24.5 on channel stable at /Users/gunpreetsingh/Developer/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision dec2ee5c1f (4 weeks ago), 2024-11-13 11:13:06 -0800
• Engine revision a18df97ca5
• Dart version 3.5.4
• DevTools version 2.37.3
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /Users/gunpreetsingh/Library/Android/sdk
• Platform android-34, build-tools 31.0.0
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[!] Xcode - develop for iOS and macOS (Xcode 16.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16B40
! iOS 18.1 Simulator not installed; this may be necessary for iOS and macOS development.
To download and install the platform, open Xcode, select Xcode > Settings > Platforms,
and click the GET button for the required platform.
For more information, please visit:
https://developer.apple.com/documentation/xcode/installing-additional-simulator-runtimes
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2020.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
[✓] VS Code (version 1.95.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.102.0
[✓] Connected device (3 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 15.1 24B83 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.1 24B83 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 131.0.6778.109
! Error: Browsing on the local area network for Gunpreet’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local
area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.
Steps to reproduce
We're using the package 'dio', received data from a POST API, the string bytes in the response get converted to Map<String, dynamic> object.
Flutter logs an error on the Debug Console: "Bad UTF-8 encoding (U+FFFD; REPLACEMENT CHARACTER) found while decoding string: The Flutter team would greatly appreciate if you could file a bug explaining exactly what you were doing when this happened:
https://github.com/flutter/flutter/issues/new/choose
The source bytes were:
[27, 91, 51, 56, 59, 53, 59, 50, 52, 52, 109, 226, 148, ..."
Expected results
The application should not have exit unexpectedly. The API request is already placed inside a try-catch block, the catch block should have been executed.
Actual results
Flutter Web Exit Unexpectedly
Code sample
Code sample
Screenshots or Video
Screenshots / Video demonstration
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output