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

The getter 'requestLock' isn't defined for the type 'Interceptors'. #2112

Closed
zubair999 opened this issue Feb 17, 2024 · 1 comment
Closed

Comments

@zubair999
Copy link

Package

dio

Version

5.4.0

Operating-System

Windows

Output of flutter doctor -v

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.16.9, on Microsoft Windows [Version 10.0.19045.3930], locale en-US)
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    ✗ cmdline-tools component is missing
      Run `path/to/sdkmanager --install "cmdline-tools;latest"`
      See https://developer.android.com/studio/command-line for more details.
    ✗ Android license status unknown.
      Run `flutter doctor --android-licenses` to accept the SDK licenses.
      See https://flutter.dev/docs/get-started/install/windows#android-setup for more details.
[✓] Chrome - develop for the web
[✗] Visual Studio - develop Windows apps
    ✗ Visual Studio not installed; this is necessary to develop Windows apps.
      Download at https://visualstudio.microsoft.com/downloads/.
      Please install the "Desktop development with C++" workload, including all of its default components
[✓] Android Studio (version 2023.1)
[✓] VS Code (version 1.86.2)
[✓] Connected device (4 available)

Dart Version

3.2.6

Steps to Reproduce

`
@riverpod
Dio dio(DioRef ref) {
final dio = Dio();
dio.interceptors.add(InterceptorsWrapper(
onRequest: (RequestOptions requestOptions,
RequestInterceptorHandler handler) async {
requestOptions.baseUrl = baseurl;
var accessToken = await storage.read(key: 'accessToken');
requestOptions.headers
.putIfAbsent('Authorization', () => 'Bearer $accessToken');
handler.next(requestOptions);
},
onError: (DioException err, ErrorInterceptorHandler handler) async {

  if (err.response?.statusCode == 401) {
    dio.interceptors.requestLock.lock();
    dio.interceptors.responseLock.lock();
  }
}

));
return dio;
}
`

Expected Result

`
@riverpod
Dio dio(DioRef ref) {
final dio = Dio();
dio.interceptors.add(InterceptorsWrapper(
onRequest: (RequestOptions requestOptions,
RequestInterceptorHandler handler) async {
requestOptions.baseUrl = baseurl;
var accessToken = await storage.read(key: 'accessToken');
requestOptions.headers
.putIfAbsent('Authorization', () => 'Bearer $accessToken');
handler.next(requestOptions);
},
onError: (DioException err, ErrorInterceptorHandler handler) async {

  if (err.response?.statusCode == 401) {
    dio.interceptors.requestLock.lock();
    dio.interceptors.responseLock.lock();
  }
}

));
return dio;
}
`

Actual Result

`
@riverpod
Dio dio(DioRef ref) {
final dio = Dio();
dio.interceptors.add(InterceptorsWrapper(
onRequest: (RequestOptions requestOptions,
RequestInterceptorHandler handler) async {
requestOptions.baseUrl = baseurl;
var accessToken = await storage.read(key: 'accessToken');
requestOptions.headers
.putIfAbsent('Authorization', () => 'Bearer $accessToken');
handler.next(requestOptions);
},
onError: (DioException err, ErrorInterceptorHandler handler) async {

  if (err.response?.statusCode == 401) {
    dio.interceptors.requestLock.lock();
    dio.interceptors.responseLock.lock();
  }
}

));
return dio;
}
`

@zubair999 zubair999 added h: need triage This issue needs to be categorized s: bug Something isn't working labels Feb 17, 2024
@AlexV525
Copy link
Member

Use QueuedInterceptor as the doc and the breaking change note suggested.

@AlexV525 AlexV525 closed this as not planned Won't fix, can't repro, duplicate, stale Feb 17, 2024
@AlexV525 AlexV525 added i: not reading documents and removed h: need triage This issue needs to be categorized s: bug Something isn't working labels Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants