Your settings in AndroidManifest.xml and network_security_config.xmlonly apply to Android’s native HTTP stack, not to Dart/Dio in Flutter.
Dart (and packages like Dio) use their own networking stack (based on dart:io), which ignores Android’s usesCleartextTraffic and network_security_config settings.
Solution:
To block HTTP traffic in Flutter:
Manually enforce HTTPS in your Dart code. You must avoid sending any http:// requests. You can:
Search for and disallow all http:// URLs.
Use a wrapper or interceptor in Dio to reject non-HTTPS URLs.
Use a Dio interceptor to block HTTP:
Dio dio = Dio();
dio.interceptors.add(InterceptorsWrapper(
onRequest: (options, handler) {
if (options.uri.scheme != 'https') {
return handler.reject(
DioError(
requestOptions: options,
error: 'Cleartext HTTP is not allowed.',
type: DioErrorType.badResponse,
),
);
}
return handler.next(options);
},
));
Summary:
AndroidManifest and network config do not affect Dart/Dio.
You must block HTTP manually in Dart code.
Use a Dio interceptor or audit your requests to enforce HTTPS.