NetworkInspector class
This class is called in multiple place, first it's needed to called on the initial phase of the application in order to initialized the local database for http activities log
NetworkInspector.initialize();
Then it's needed for invoked to network interceptors constructor Dio example
Dio(
BaseOptions(
baseUrl: 'http://192.168.1.6:8000/',
connectTimeout: 10 * 1000, // 10 second
headers: {
'Content-type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer i109gh23j9u1h3811io2n391'
},
),
)..interceptors.add(
DioInterceptor(
logIsAllowed: true,
networkInspector: networkInspector,
onHttpFinish: (hashCode, title, message) {
notifyActivity(
title: title,
message: message,
);
},
),
)
Http example
HttpInterceptor(
logIsAllowed: true,
client: client,
baseUrl: Uri.parse('http://192.168.1.3:8000/'),
networkInspector: networkInspector,
onHttpFinish: (hashCode, title, message) {
notifyActivity(
title: title,
message: message,
);
},
headers: {
'Content-type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer WEKLSSS'
},
);
Constructors
Properties
- database ↔ Database?
-
Dependency injection
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- logDatasource ↔ LogDatasource?
-
getter/setter pair
- logHttpRequest ↔ LogHttpRequest?
-
getter/setter pair
- logHttpResponse ↔ LogHttpResponse?
-
getter/setter pair
- logRepository ↔ LogRepository?
-
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
injectDependencies(
) → Future< void> -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
writeHttpRequestLog(
HttpRequest param) → Future< bool?> - writeHttpRequestLog is used to log http request data,
-
writeHttpResponseLog(
HttpResponse param) → Future< bool?> - writeHttpResponseLog is used to log http response data
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
initialize(
) → Future< void> - Call this method on the main initialization