mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 13:36:50 +00:00
Context fixes
This commit is contained in:
parent
657a36e14f
commit
dce3b6c14a
22
lib/api.dart
22
lib/api.dart
@ -37,13 +37,15 @@ class InvenTreeFileService extends FileService {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<FileServiceResponse> get(String url,
|
Future<FileServiceResponse> get(String url,
|
||||||
{Map<String, String> headers = const {}}) async {
|
{Map<String, String>? headers}) async {
|
||||||
final Uri resolved = Uri.base.resolve(url);
|
final Uri resolved = Uri.base.resolve(url);
|
||||||
final HttpClientRequest req = await _client!.getUrl(resolved);
|
final HttpClientRequest req = await _client!.getUrl(resolved);
|
||||||
|
|
||||||
headers.forEach((key, value) {
|
if (headers != null) {
|
||||||
req.headers.add(key, value);
|
headers.forEach((key, value) {
|
||||||
});
|
req.headers.add(key, value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
final HttpClientResponse httpResponse = await req.close();
|
final HttpClientResponse httpResponse = await req.close();
|
||||||
final http.StreamedResponse _response = http.StreamedResponse(
|
final http.StreamedResponse _response = http.StreamedResponse(
|
||||||
@ -458,7 +460,7 @@ class InvenTreeAPI {
|
|||||||
error.toString(),
|
error.toString(),
|
||||||
);
|
);
|
||||||
} else if (error is TimeoutException) {
|
} else if (error is TimeoutException) {
|
||||||
showTimeoutError(ctx);
|
showTimeoutError();
|
||||||
} else {
|
} else {
|
||||||
showServerError(
|
showServerError(
|
||||||
L10().serverError,
|
L10().serverError,
|
||||||
@ -499,7 +501,7 @@ class InvenTreeAPI {
|
|||||||
error.toString()
|
error.toString()
|
||||||
);
|
);
|
||||||
} else if (error is TimeoutException) {
|
} else if (error is TimeoutException) {
|
||||||
showTimeoutError(ctx);
|
showTimeoutError();
|
||||||
} else {
|
} else {
|
||||||
showServerError(
|
showServerError(
|
||||||
L10().serverError,
|
L10().serverError,
|
||||||
@ -587,7 +589,7 @@ class InvenTreeAPI {
|
|||||||
error.toString()
|
error.toString()
|
||||||
);
|
);
|
||||||
} else if (error is TimeoutException) {
|
} else if (error is TimeoutException) {
|
||||||
showTimeoutError(ctx);
|
showTimeoutError();
|
||||||
} else {
|
} else {
|
||||||
showServerError(
|
showServerError(
|
||||||
L10().serverError,
|
L10().serverError,
|
||||||
@ -718,7 +720,7 @@ class InvenTreeAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open a connection
|
// Open a connection
|
||||||
HttpClientRequest request = await client.getUrl(uri)
|
HttpClientRequest? request = await client.getUrl(uri)
|
||||||
.timeout(Duration(seconds: 10))
|
.timeout(Duration(seconds: 10))
|
||||||
.catchError((error) {
|
.catchError((error) {
|
||||||
print("GET request returned error");
|
print("GET request returned error");
|
||||||
@ -733,7 +735,7 @@ class InvenTreeAPI {
|
|||||||
error.toString()
|
error.toString()
|
||||||
);
|
);
|
||||||
} else if (error is TimeoutException) {
|
} else if (error is TimeoutException) {
|
||||||
showTimeoutError(ctx);
|
showTimeoutError();
|
||||||
} else {
|
} else {
|
||||||
showServerError(
|
showServerError(
|
||||||
L10().serverError,
|
L10().serverError,
|
||||||
@ -767,7 +769,7 @@ class InvenTreeAPI {
|
|||||||
error.toString()
|
error.toString()
|
||||||
);
|
);
|
||||||
} else if (error is TimeoutException) {
|
} else if (error is TimeoutException) {
|
||||||
showTimeoutError(ctx);
|
showTimeoutError();
|
||||||
} else {
|
} else {
|
||||||
showServerError(
|
showServerError(
|
||||||
L10().serverError,
|
L10().serverError,
|
||||||
|
@ -248,8 +248,7 @@ class BarcodeScanHandler extends BarcodeHandler {
|
|||||||
|
|
||||||
var _ctx = OneContext().context;
|
var _ctx = OneContext().context;
|
||||||
|
|
||||||
showDialog(
|
OneContext().showDialog(
|
||||||
context: _ctx,
|
|
||||||
builder: (BuildContext context) => SimpleDialog(
|
builder: (BuildContext context) => SimpleDialog(
|
||||||
title: Text(L10().unknownResponse),
|
title: Text(L10().unknownResponse),
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
|
Loading…
x
Reference in New Issue
Block a user