2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-04-28 13:36:50 +00:00

More cleanup

This commit is contained in:
Oliver 2021-07-15 23:28:55 +10:00
parent d2ce3fadf1
commit 83e29777c2
12 changed files with 23 additions and 60 deletions

View File

@ -272,9 +272,6 @@ class StockItemBarcodeAssignmentHandler extends BarcodeHandler {
final InvenTreeStockItem item;
StockItemBarcodeAssignmentHandler(this.item) {
if (item == null) {
throw new AssertionError("null StockItem passed to barcode handler");
}
}
@override
@ -354,11 +351,7 @@ class StockItemScanIntoLocationHandler extends BarcodeHandler {
final InvenTreeStockItem item;
StockItemScanIntoLocationHandler(this.item) {
if (item == null) {
throw new AssertionError("null StockItem passed to StockItemScanIntoLocationHandler");
}
}
StockItemScanIntoLocationHandler(this.item);
@override
String getOverlayText(BuildContext context) => L10().barcodeScanLocation;
@ -419,11 +412,7 @@ class StockLocationScanInItemsHandler extends BarcodeHandler {
final InvenTreeStockLocation location;
StockLocationScanInItemsHandler(this.location) {
if (location == null) {
throw new AssertionError("null StockLocation passed to StockLocationScanInItemsHandler");
}
}
StockLocationScanInItemsHandler(this.location);
@override
String getOverlayText(BuildContext context) => L10().barcodeScanItem;

View File

@ -19,11 +19,7 @@ class InvenTreePageResponse {
}
// Total number of results in the dataset
int _count = 0;
void set count(int v) { _count = v; }
int get count => _count;
int count = 0;
int get length => results.length;

View File

@ -48,9 +48,7 @@ class InvenTreePartCategory extends InvenTreeModel {
InvenTreePartCategory() : super();
InvenTreePartCategory.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
}
InvenTreePartCategory.fromJson(Map<String, dynamic> json) : super.fromJson(json);
@override
InvenTreeModel createFromJson(Map<String, dynamic> json) {
@ -85,8 +83,7 @@ class InvenTreePartTestTemplate extends InvenTreeModel {
InvenTreePartTestTemplate() : super();
InvenTreePartTestTemplate.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
}
InvenTreePartTestTemplate.fromJson(Map<String, dynamic> json) : super.fromJson(json);
@override
InvenTreeModel createFromJson(Map<String, dynamic> json) {
@ -309,11 +306,6 @@ class InvenTreePart extends InvenTreeModel {
name: 'image',
);
if (response == null) {
print("uploadImage returned null at '${url}'");
return false;
}
if (response.statusCode != 200) {
print("uploadImage returned ${response.statusCode} at '${url}'");
return false;

View File

@ -1,12 +1,8 @@
import 'dart:io';
import 'package:device_info/device_info.dart';
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:package_info/package_info.dart';
import 'package:sentry_flutter/sentry_flutter.dart';
import 'package:one_context/one_context.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:InvenTree/api.dart';
@ -108,13 +104,14 @@ Future<bool> sentryReportMessage(String message, {Map<String, String>? context})
}
});
final sentryId = await Sentry.captureMessage(message).catchError((error) {
try {
await Sentry.captureMessage(message);
return true;
} catch (error) {
print("Error uploading sentry messages...");
print(error);
return null;
});
return sentryId != null;
return false;
}
}

View File

@ -188,11 +188,11 @@ class InvenTreeStockItem extends InvenTreeModel {
"result": result.toString(),
};
if (value != null && !value.isEmpty) {
if (value != null && value.isNotEmpty) {
data["value"] = value;
}
if (notes != null && !notes.isEmpty) {
if (notes != null && notes.isNotEmpty) {
data["notes"] = notes;
}
@ -211,8 +211,6 @@ class InvenTreeStockItem extends InvenTreeModel {
// Check that the HTTP status code is HTTP_201_CREATED
return _uploadResponse.statusCode == 201;
}
return false;
}
String get uid => jsondata['uid'] ?? '';

View File

@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'package:InvenTree/inventree/sentry.dart';
import 'package:flutter_localizations/flutter_localizations.dart';

View File

@ -54,10 +54,6 @@ class InvenTreePreferencesDB {
class InvenTreePreferences {
static const String _SERVER = 'server';
static const String _USERNAME = 'username';
static const String _PASSWORD = 'password';
/* The following settings are not stored to persistent storage,
* instead they are only used as 'session preferences'.
* They are kept here as a convenience only.

View File

@ -9,7 +9,7 @@ import 'package:InvenTree/widget/refreshable_state.dart';
abstract class CompanyListWidget extends StatefulWidget {
String title = "";
final String title = "";
Map<String, String> filters = {};
@override

View File

@ -22,7 +22,7 @@ Future<void> confirmationDialog(String title, String text, {String? acceptText,
),
content: Text(text),
actions: [
FlatButton(
TextButton(
child: Text(_reject),
onPressed: () {
// Close this dialog
@ -33,7 +33,7 @@ Future<void> confirmationDialog(String title, String text, {String? acceptText,
}
}
),
FlatButton(
TextButton(
child: Text(_accept),
onPressed: () {
// Close this dialog
@ -176,7 +176,7 @@ void showFormDialog(String title, {String? acceptText, String? cancelText, Globa
// Undefined actions = OK + Cancel
if (actions == null) {
actions = <Widget>[
FlatButton(
TextButton(
child: Text(_cancel),
onPressed: () {
// Close the form
@ -186,7 +186,7 @@ void showFormDialog(String title, {String? acceptText, String? cancelText, Globa
}
}
),
FlatButton(
TextButton(
child: Text(_accept),
onPressed: () {

View File

@ -71,13 +71,13 @@ class ImagePickerField extends FormField<File> {
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
FlatButton(
TextButton(
child: Text(L10().selectImage),
onPressed: () {
_selectFromGallery(state);
},
),
FlatButton(
TextButton(
child: Text(L10().takePicture),
onPressed: () {
_selectFromCamera(state);

View File

@ -199,9 +199,7 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart?> {
// Ensure the search theme matches the app theme
@override
ThemeData appBarTheme(BuildContext context) {
assert(context != null);
final ThemeData theme = Theme.of(context);
assert(theme != null);
return theme;
}
}
@ -389,9 +387,7 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem?> {
// Ensure the search theme matches the app theme
@override
ThemeData appBarTheme(BuildContext context) {
assert(context != null);
final ThemeData theme = Theme.of(context);
assert(theme != null);
return theme;
}
}

View File

@ -392,7 +392,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
}
// Location information
if ((item.locationId > 0) && (item.locationName != null) && (item.locationName.isNotEmpty)) {
if ((item.locationId > 0) && (item.locationName.isNotEmpty)) {
tiles.add(
ListTile(
title: Text(L10().stockLocation),
@ -581,7 +581,7 @@ class _StockItemDisplayState extends RefreshableState<StockDetailWidget> {
);
// Add or remove custom barcode
if (item != null && item.uid.isEmpty) {
if (item.uid.isEmpty) {
tiles.add(
ListTile(
title: Text(L10().barcodeAssign),