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

View File

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

View File

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

View File

@ -1,12 +1,8 @@
import 'dart:io'; import 'dart:io';
import 'package:device_info/device_info.dart'; 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:package_info/package_info.dart';
import 'package:sentry_flutter/sentry_flutter.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'; 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 uploading sentry messages...");
print(error); print(error);
return null; return false;
}); }
return sentryId != null;
} }

View File

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

View File

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

View File

@ -54,10 +54,6 @@ class InvenTreePreferencesDB {
class InvenTreePreferences { 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, /* The following settings are not stored to persistent storage,
* instead they are only used as 'session preferences'. * instead they are only used as 'session preferences'.
* They are kept here as a convenience only. * 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 { abstract class CompanyListWidget extends StatefulWidget {
String title = ""; final String title = "";
Map<String, String> filters = {}; Map<String, String> filters = {};
@override @override

View File

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

View File

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

View File

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

View File

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