Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is an Interceptor in dart?

Tags:

dart

I frequently come across the Interceptor base class in the dart docs, but the link is broken. Does anyone know what is an interceptor?

For instance the Storage class derives from Interceptor http://api.dartlang.org/docs/releases/latest/dart_html/Storage.html

like image 493
jz87 Avatar asked Jun 07 '13 21:06

jz87


People also ask

What is the use of interceptor?

Whenever a request is made, the interceptors handle it in between. They can also identify the response by performing Rxjs operators. The interceptors do not initiate the handle method and handle the requests at their level. The interceptor is used to perform various functions and methods to perform specific tasks.

What is the use of interceptors in flutter?

Interceptors as the name suggest, intercept something. It basically allows us to intercept incoming or outgoing HTTP requests using the HttpClient. Interceptors are a way to do some work for every single HTTP request or response.

How do you make an interceptor in flutter?

Add Dio as a network client package in the dependency section of your pubspec. yaml file and import it. Create a Dio object, you can use the log interceptors to read while making HTTP calls. This interceptor will help you create all the logs while making the HTTP request and response as well.


1 Answers

When you open the declaration of any such type in DartEditor, it turns out that it is actually derived from NativeFieldWrapperClass1 class.

NativeFieldWrapperClass1 class is used as the base class for types which have a native implementation in environments which embed Dart VM, e.g. classes which wrap DOM elements - canvas DOM element is implemented in browser and wrapped into CanvasElement Dart class.

Instances of such types have their peers in native implementation (CanvasElement instance has native peer C/C++ object in the browser). Deriving from NativeFieldWrapperClass1 ensures they have a slot where embedders can store a pointer to the peer object - native data. This is done with embedder API (Dart_SetNativeInstanceField function).

like image 66
Zdeslav Vojkovic Avatar answered Sep 23 '22 18:09

Zdeslav Vojkovic