onRequest method
Called when the request is about to be sent.
Implementation
@override
void onRequest(
RequestOptions options,
RequestInterceptorHandler handler,
) async {
// Get the current locale
final locale = WidgetsBinding.instance.platformDispatcher.locale;
// Add locale information to headers
options.headers['Accept-Language'] = locale.toString();
options.headers['Language'] = locale.languageCode.toUpperCase();
if (locale.countryCode != null) {
options.headers['Country'] = locale.countryCode?.toUpperCase();
}
if (locale.scriptCode != null) {
options.headers['Script'] = locale.scriptCode;
}
options.headers['Timezone'] = 'Asia/Seoul';
options.headers['Timezone-Offset'] =
DateTime.now().timeZoneOffset.inMinutes;
handler.next(options);
}