diff --git a/lib/barcode.dart b/lib/barcode.dart index 100c0d54..d43707c4 100644 --- a/lib/barcode.dart +++ b/lib/barcode.dart @@ -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; diff --git a/lib/inventree/model.dart b/lib/inventree/model.dart index 9953c659..76d558b3 100644 --- a/lib/inventree/model.dart +++ b/lib/inventree/model.dart @@ -19,12 +19,8 @@ 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; List results = []; diff --git a/lib/inventree/part.dart b/lib/inventree/part.dart index 4cf593aa..22bee60f 100644 --- a/lib/inventree/part.dart +++ b/lib/inventree/part.dart @@ -48,9 +48,7 @@ class InvenTreePartCategory extends InvenTreeModel { InvenTreePartCategory() : super(); - InvenTreePartCategory.fromJson(Map json) : super.fromJson(json) { - - } + InvenTreePartCategory.fromJson(Map json) : super.fromJson(json); @override InvenTreeModel createFromJson(Map json) { @@ -85,8 +83,7 @@ class InvenTreePartTestTemplate extends InvenTreeModel { InvenTreePartTestTemplate() : super(); - InvenTreePartTestTemplate.fromJson(Map json) : super.fromJson(json) { - } + InvenTreePartTestTemplate.fromJson(Map json) : super.fromJson(json); @override InvenTreeModel createFromJson(Map 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; diff --git a/lib/inventree/sentry.dart b/lib/inventree/sentry.dart index da729e0a..4e4e4f2a 100644 --- a/lib/inventree/sentry.dart +++ b/lib/inventree/sentry.dart @@ -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 sentryReportMessage(String message, {Map? 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; + } } diff --git a/lib/inventree/stock.dart b/lib/inventree/stock.dart index da2999fb..4242d79b 100644 --- a/lib/inventree/stock.dart +++ b/lib/inventree/stock.dart @@ -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'] ?? ''; diff --git a/lib/main.dart b/lib/main.dart index a84abe83..ecf7097c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:io'; import 'package:InvenTree/inventree/sentry.dart'; import 'package:flutter_localizations/flutter_localizations.dart'; diff --git a/lib/preferences.dart b/lib/preferences.dart index 27a416f0..f6e2372f 100644 --- a/lib/preferences.dart +++ b/lib/preferences.dart @@ -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. diff --git a/lib/widget/company_list.dart b/lib/widget/company_list.dart index f3cb207a..090784d3 100644 --- a/lib/widget/company_list.dart +++ b/lib/widget/company_list.dart @@ -9,7 +9,7 @@ import 'package:InvenTree/widget/refreshable_state.dart'; abstract class CompanyListWidget extends StatefulWidget { - String title = ""; + final String title = ""; Map filters = {}; @override diff --git a/lib/widget/dialogs.dart b/lib/widget/dialogs.dart index 725b5e52..dfa7edcf 100644 --- a/lib/widget/dialogs.dart +++ b/lib/widget/dialogs.dart @@ -22,7 +22,7 @@ Future 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 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 = [ - 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: () { diff --git a/lib/widget/fields.dart b/lib/widget/fields.dart index 87a62477..53126604 100644 --- a/lib/widget/fields.dart +++ b/lib/widget/fields.dart @@ -71,13 +71,13 @@ class ImagePickerField extends FormField { child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - FlatButton( + TextButton( child: Text(L10().selectImage), onPressed: () { _selectFromGallery(state); }, ), - FlatButton( + TextButton( child: Text(L10().takePicture), onPressed: () { _selectFromCamera(state); diff --git a/lib/widget/search.dart b/lib/widget/search.dart index 97ccde01..f6fb1c1b 100644 --- a/lib/widget/search.dart +++ b/lib/widget/search.dart @@ -199,9 +199,7 @@ class PartSearchDelegate extends SearchDelegate { // 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 { // 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; } } \ No newline at end of file diff --git a/lib/widget/stock_detail.dart b/lib/widget/stock_detail.dart index 2517c9dc..d8ef4a17 100644 --- a/lib/widget/stock_detail.dart +++ b/lib/widget/stock_detail.dart @@ -392,7 +392,7 @@ class _StockItemDisplayState extends RefreshableState { } // 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 { ); // Add or remove custom barcode - if (item != null && item.uid.isEmpty) { + if (item.uid.isEmpty) { tiles.add( ListTile( title: Text(L10().barcodeAssign),