mirror of
https://github.com/inventree/inventree-app.git
synced 2025-04-28 05:26:47 +00:00
More linting again
This commit is contained in:
parent
77bac9af36
commit
be36811cb3
@ -35,6 +35,8 @@ linter:
|
|||||||
|
|
||||||
unnecessary_string_interpolations: false
|
unnecessary_string_interpolations: false
|
||||||
|
|
||||||
|
prefer_interpolation_to_compose_strings: false
|
||||||
|
|
||||||
no_logic_in_create_state: false
|
no_logic_in_create_state: false
|
||||||
|
|
||||||
parameter_assignments: false
|
parameter_assignments: false
|
||||||
@ -59,3 +61,5 @@ linter:
|
|||||||
|
|
||||||
# Blindly follow the Flutter code style, which prefers types everywhere
|
# Blindly follow the Flutter code style, which prefers types everywhere
|
||||||
always_specify_types: false
|
always_specify_types: false
|
||||||
|
|
||||||
|
avoid_unnecessary_containers: false
|
||||||
|
@ -55,7 +55,7 @@ class APIFormField {
|
|||||||
bool get multiline => (data["multiline"] ?? false) as bool;
|
bool get multiline => (data["multiline"] ?? false) as bool;
|
||||||
|
|
||||||
// Get the "value" as a string (look for "default" if not available)
|
// Get the "value" as a string (look for "default" if not available)
|
||||||
dynamic get value => (data["value"] ?? data["default"]);
|
dynamic get value => data["value"] ?? data["default"];
|
||||||
|
|
||||||
// Get the "default" as a string
|
// Get the "default" as a string
|
||||||
dynamic get defaultValue => data["default"];
|
dynamic get defaultValue => data["default"];
|
||||||
@ -92,7 +92,7 @@ class APIFormField {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasErrors() => errorMessages().length > 0;
|
bool hasErrors() => errorMessages().isNotEmpty;
|
||||||
|
|
||||||
// Return the error message associated with this field
|
// Return the error message associated with this field
|
||||||
List<String> errorMessages() {
|
List<String> errorMessages() {
|
||||||
@ -660,7 +660,7 @@ Future<void> launchApiForm(BuildContext context, String title, String url, Map<S
|
|||||||
|
|
||||||
class APIFormWidget extends StatefulWidget {
|
class APIFormWidget extends StatefulWidget {
|
||||||
|
|
||||||
APIFormWidget(
|
const APIFormWidget(
|
||||||
this.title,
|
this.title,
|
||||||
this.url,
|
this.url,
|
||||||
this.fields,
|
this.fields,
|
||||||
@ -685,7 +685,7 @@ class APIFormWidget extends StatefulWidget {
|
|||||||
|
|
||||||
final List<APIFormField> fields;
|
final List<APIFormField> fields;
|
||||||
|
|
||||||
Function(Map<String, dynamic>)? onSuccess;
|
final Function(Map<String, dynamic>)? onSuccess;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_APIFormWidgetState createState() => _APIFormWidgetState(title, url, fields, method, onSuccess, fileField);
|
_APIFormWidgetState createState() => _APIFormWidgetState(title, url, fields, method, onSuccess, fileField);
|
||||||
|
@ -49,7 +49,7 @@ class InvenTreeModel {
|
|||||||
|
|
||||||
// Override the web URL for each subclass
|
// Override the web URL for each subclass
|
||||||
// Note: If the WEB_URL is the same (except for /api/) as URL then just leave blank
|
// Note: If the WEB_URL is the same (except for /api/) as URL then just leave blank
|
||||||
String WEB_URL = "";
|
String get WEB_URL => "";
|
||||||
|
|
||||||
String get webUrl {
|
String get webUrl {
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ class InvenTreeModel {
|
|||||||
Map<String, dynamic> jsondata = {};
|
Map<String, dynamic> jsondata = {};
|
||||||
|
|
||||||
// Accessor for the API
|
// Accessor for the API
|
||||||
var api = InvenTreeAPI();
|
InvenTreeAPI api = InvenTreeAPI();
|
||||||
|
|
||||||
int get pk => (jsondata["pk"] ?? -1) as int;
|
int get pk => (jsondata["pk"] ?? -1) as int;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class InvenTreePartCategory extends InvenTreeModel {
|
|||||||
// TODO - Drive the refactor tractor through this
|
// TODO - Drive the refactor tractor through this
|
||||||
List<String> psplit = pathstring.split("/");
|
List<String> psplit = pathstring.split("/");
|
||||||
|
|
||||||
if (psplit.length > 0) {
|
if (psplit.isNotEmpty) {
|
||||||
psplit.removeLast();
|
psplit.removeLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ class InvenTreeStockItem extends InvenTreeModel {
|
|||||||
String get URL => "stock/";
|
String get URL => "stock/";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String WEB_URL = "stock/item/";
|
String get WEB_URL => "stock/item/";
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, dynamic> formFields() {
|
Map<String, dynamic> formFields() {
|
||||||
@ -549,7 +549,7 @@ class InvenTreeStockLocation extends InvenTreeModel {
|
|||||||
// TODO - Drive the refactor tractor through this
|
// TODO - Drive the refactor tractor through this
|
||||||
List<String> psplit = pathstring.split("/");
|
List<String> psplit = pathstring.split("/");
|
||||||
|
|
||||||
if (psplit.length > 0) {
|
if (psplit.isNotEmpty) {
|
||||||
psplit.removeLast();
|
psplit.removeLast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,24 +79,6 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future <void> _updateProfile(UserProfile? profile) async {
|
|
||||||
|
|
||||||
if (profile == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_reload();
|
|
||||||
|
|
||||||
if (InvenTreeAPI().isConnected() && InvenTreeAPI().profile != null && profile.key == (InvenTreeAPI().profile?.key ?? "")) {
|
|
||||||
// Attempt server login (this will load the newly selected profile
|
|
||||||
|
|
||||||
InvenTreeAPI().connectToServer().then((result) {
|
|
||||||
_reload();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Widget? _getProfileIcon(UserProfile profile) {
|
Widget? _getProfileIcon(UserProfile profile) {
|
||||||
|
|
||||||
// Not selected? No icon for you!
|
// Not selected? No icon for you!
|
||||||
@ -134,7 +116,7 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
|||||||
|
|
||||||
List<Widget> children = [];
|
List<Widget> children = [];
|
||||||
|
|
||||||
if (profiles.length > 0) {
|
if (profiles.isNotEmpty) {
|
||||||
for (int idx = 0; idx < profiles.length; idx++) {
|
for (int idx = 0; idx < profiles.length; idx++) {
|
||||||
UserProfile profile = profiles[idx];
|
UserProfile profile = profiles[idx];
|
||||||
|
|
||||||
@ -237,9 +219,9 @@ class _InvenTreeLoginSettingsState extends State<InvenTreeLoginSettingsWidget> {
|
|||||||
|
|
||||||
class ProfileEditWidget extends StatefulWidget {
|
class ProfileEditWidget extends StatefulWidget {
|
||||||
|
|
||||||
ProfileEditWidget(this.profile) : super();
|
const ProfileEditWidget(this.profile) : super();
|
||||||
|
|
||||||
UserProfile? profile;
|
final UserProfile? profile;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ProfileEditState createState() => _ProfileEditState(profile);
|
_ProfileEditState createState() => _ProfileEditState(profile);
|
||||||
|
@ -198,7 +198,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
|||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
tiles.add(progressIndicator());
|
tiles.add(progressIndicator());
|
||||||
} else if (_subcategories.length == 0) {
|
} else if (_subcategories.isEmpty) {
|
||||||
tiles.add(ListTile(
|
tiles.add(ListTile(
|
||||||
title: Text(L10().noSubcategories),
|
title: Text(L10().noSubcategories),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
@ -301,7 +301,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tiles.length == 0) {
|
if (tiles.isEmpty) {
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(
|
title: Text(
|
||||||
@ -397,11 +397,11 @@ class SubcategoryList extends StatelessWidget {
|
|||||||
|
|
||||||
class PaginatedPartList extends StatefulWidget {
|
class PaginatedPartList extends StatefulWidget {
|
||||||
|
|
||||||
PaginatedPartList(this.filters, {this.onTotalChanged});
|
const PaginatedPartList(this.filters, {this.onTotalChanged});
|
||||||
|
|
||||||
final Map<String, String> filters;
|
final Map<String, String> filters;
|
||||||
|
|
||||||
Function(int)? onTotalChanged;
|
final Function(int)? onTotalChanged;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_PaginatedPartListState createState() => _PaginatedPartListState(filters, onTotalChanged);
|
_PaginatedPartListState createState() => _PaginatedPartListState(filters, onTotalChanged);
|
||||||
|
@ -15,11 +15,11 @@ import "package:inventree/l10.dart";
|
|||||||
|
|
||||||
class CompanyListWidget extends StatefulWidget {
|
class CompanyListWidget extends StatefulWidget {
|
||||||
|
|
||||||
CompanyListWidget(this.title, this.filters, {Key? key}) : super(key: key);
|
const CompanyListWidget(this.title, this.filters, {Key? key}) : super(key: key);
|
||||||
|
|
||||||
String title;
|
final String title;
|
||||||
|
|
||||||
Map<String, String> filters;
|
final Map<String, String> filters;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_CompanyListWidgetState createState() => _CompanyListWidgetState(title, filters);
|
_CompanyListWidgetState createState() => _CompanyListWidgetState(title, filters);
|
||||||
@ -49,11 +49,11 @@ class _CompanyListWidgetState extends RefreshableState<CompanyListWidget> {
|
|||||||
|
|
||||||
class PaginatedCompanyList extends StatefulWidget {
|
class PaginatedCompanyList extends StatefulWidget {
|
||||||
|
|
||||||
PaginatedCompanyList(this.filters, {this.onTotalChanged});
|
const PaginatedCompanyList(this.filters, {this.onTotalChanged});
|
||||||
|
|
||||||
final Map<String, String> filters;
|
final Map<String, String> filters;
|
||||||
|
|
||||||
Function(int)? onTotalChanged;
|
final Function(int)? onTotalChanged;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_CompanyListState createState() => _CompanyListState(filters, onTotalChanged);
|
_CompanyListState createState() => _CompanyListState(filters, onTotalChanged);
|
||||||
|
@ -194,7 +194,7 @@ class StringField extends TextFormField {
|
|||||||
*/
|
*/
|
||||||
class QuantityField extends TextFormField {
|
class QuantityField extends TextFormField {
|
||||||
|
|
||||||
QuantityField({String label = "", String hint = "", String initial = "", double? max, TextEditingController? controller}) :
|
QuantityField({String label = "", String hint = "", double? max, TextEditingController? controller}) :
|
||||||
super(
|
super(
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
labelText: label,
|
labelText: label,
|
||||||
|
@ -313,13 +313,13 @@ List<Widget> detailTiles() {
|
|||||||
L10().sublocations,
|
L10().sublocations,
|
||||||
style: TextStyle(fontWeight: FontWeight.bold),
|
style: TextStyle(fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
trailing: sublocations.length > 0 ? Text("${sublocations.length}") : null,
|
trailing: sublocations.isNotEmpty ? Text("${sublocations.length}") : null,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
tiles.add(progressIndicator());
|
tiles.add(progressIndicator());
|
||||||
} else if (_sublocations.length > 0) {
|
} else if (_sublocations.isNotEmpty) {
|
||||||
tiles.add(SublocationList(_sublocations));
|
tiles.add(SublocationList(_sublocations));
|
||||||
} else {
|
} else {
|
||||||
tiles.add(ListTile(
|
tiles.add(ListTile(
|
||||||
|
@ -5,13 +5,13 @@ import "package:inventree/l10.dart";
|
|||||||
|
|
||||||
class PaginatedSearchWidget extends StatelessWidget {
|
class PaginatedSearchWidget extends StatelessWidget {
|
||||||
|
|
||||||
PaginatedSearchWidget(this.controller, this.onChanged, this.results);
|
const PaginatedSearchWidget(this.controller, this.onChanged, this.results);
|
||||||
|
|
||||||
Function onChanged;
|
final Function onChanged;
|
||||||
|
|
||||||
int results = 0;
|
final int results;
|
||||||
|
|
||||||
TextEditingController controller;
|
final TextEditingController controller;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -123,7 +123,7 @@ class _PartAttachmentDisplayState extends RefreshableState<PartAttachmentsWidget
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tiles.length == 0) {
|
if (tiles.isEmpty) {
|
||||||
tiles.add(ListTile(
|
tiles.add(ListTile(
|
||||||
title: Text(L10().attachmentNone),
|
title: Text(L10().attachmentNone),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
|
@ -17,7 +17,7 @@ import "package:inventree/widget/refreshable_state.dart";
|
|||||||
import "package:inventree/widget/part_image_widget.dart";
|
import "package:inventree/widget/part_image_widget.dart";
|
||||||
import "package:inventree/widget/stock_detail.dart";
|
import "package:inventree/widget/stock_detail.dart";
|
||||||
|
|
||||||
import "pcakage:inventree/widget/location_display.dart";
|
import "package:inventree/widget/location_display.dart";
|
||||||
|
|
||||||
|
|
||||||
class PartDetailWidget extends StatefulWidget {
|
class PartDetailWidget extends StatefulWidget {
|
||||||
@ -442,7 +442,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// TODO - Add this action back in once implemented
|
// TODO - Add this action back in once implemented
|
||||||
if (false) {
|
/*
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10().barcodeScanItem),
|
title: Text(L10().barcodeScanItem),
|
||||||
@ -453,9 +453,11 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
*/
|
||||||
|
|
||||||
if (false && !part.isActive && InvenTreeAPI().checkPermission("part", "delete")) {
|
/*
|
||||||
|
// TODO: Implement part deletion
|
||||||
|
if (!part.isActive && InvenTreeAPI().checkPermission("part", "delete")) {
|
||||||
tiles.add(
|
tiles.add(
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10().deletePart),
|
title: Text(L10().deletePart),
|
||||||
@ -467,6 +469,7 @@ class _PartDisplayState extends RefreshableState<PartDetailWidget> {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
return tiles;
|
return tiles;
|
||||||
}
|
}
|
||||||
|
@ -43,11 +43,11 @@ class _PurchaseOrderListWidgetState extends RefreshableState<PurchaseOrderListWi
|
|||||||
|
|
||||||
class _PaginatedPurchaseOrderList extends StatefulWidget {
|
class _PaginatedPurchaseOrderList extends StatefulWidget {
|
||||||
|
|
||||||
_PaginatedPurchaseOrderList(this.filters, {this.onTotalChanged});
|
const _PaginatedPurchaseOrderList(this.filters, {this.onTotalChanged});
|
||||||
|
|
||||||
final Map<String, String> filters;
|
final Map<String, String> filters;
|
||||||
|
|
||||||
Function(int)? onTotalChanged;
|
final Function(int)? onTotalChanged;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_PaginatedPurchaseOrderListState createState() => _PaginatedPurchaseOrderListState(filters, onTotalChanged);
|
_PaginatedPurchaseOrderListState createState() => _PaginatedPurchaseOrderListState(filters, onTotalChanged);
|
||||||
|
@ -9,7 +9,7 @@ abstract class RefreshableState<T extends StatefulWidget> extends State<T> {
|
|||||||
final refreshableKey = GlobalKey<ScaffoldState>();
|
final refreshableKey = GlobalKey<ScaffoldState>();
|
||||||
|
|
||||||
// Storage for context once "Build" is called
|
// Storage for context once "Build" is called
|
||||||
BuildContext? _context;
|
late BuildContext? _context;
|
||||||
|
|
||||||
// Current tab index (used for widgets which display bottom tabs)
|
// Current tab index (used for widgets which display bottom tabs)
|
||||||
int tabIndex = 0;
|
int tabIndex = 0;
|
||||||
|
@ -86,7 +86,7 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart?> {
|
|||||||
|
|
||||||
showSnackIcon(
|
showSnackIcon(
|
||||||
"${partResults.length} ${L10().results}",
|
"${partResults.length} ${L10().results}",
|
||||||
success: partResults.length > 0,
|
success: partResults.isNotEmpty,
|
||||||
icon: FontAwesomeIcons.pollH,
|
icon: FontAwesomeIcons.pollH,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart?> {
|
|||||||
|
|
||||||
search(context);
|
search(context);
|
||||||
|
|
||||||
if (query.length == 0) {
|
if (query.isEmpty) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(L10().queryEnter)
|
title: Text(L10().queryEnter)
|
||||||
);
|
);
|
||||||
@ -174,7 +174,7 @@ class PartSearchDelegate extends SearchDelegate<InvenTreePart?> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (partResults.length == 0) {
|
if (partResults.isEmpty) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(L10().noResults),
|
title: Text(L10().noResults),
|
||||||
subtitle: Text(L10().queryNoResults + " '${query}'")
|
subtitle: Text(L10().queryNoResults + " '${query}'")
|
||||||
@ -275,7 +275,7 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem?> {
|
|||||||
|
|
||||||
showSnackIcon(
|
showSnackIcon(
|
||||||
"${itemResults.length} ${L10().results}",
|
"${itemResults.length} ${L10().results}",
|
||||||
success: itemResults.length > 0,
|
success: itemResults.isNotEmpty,
|
||||||
icon: FontAwesomeIcons.pollH,
|
icon: FontAwesomeIcons.pollH,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -349,7 +349,7 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem?> {
|
|||||||
|
|
||||||
search(context);
|
search(context);
|
||||||
|
|
||||||
if (query.length == 0) {
|
if (query.isEmpty) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(L10().queryEnter)
|
title: Text(L10().queryEnter)
|
||||||
);
|
);
|
||||||
@ -362,7 +362,7 @@ class StockSearchDelegate extends SearchDelegate<InvenTreeStockItem?> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemResults.length == 0) {
|
if (itemResults.isEmpty) {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: Text(L10().noResults),
|
title: Text(L10().noResults),
|
||||||
subtitle: Text(L10().queryNoResults + " '${query}'")
|
subtitle: Text(L10().queryNoResults + " '${query}'")
|
||||||
|
@ -17,7 +17,11 @@ import "package:inventree/l10.dart";
|
|||||||
|
|
||||||
void showSnackIcon(String text, {IconData? icon, Function()? onAction, bool? success, String? actionText}) {
|
void showSnackIcon(String text, {IconData? icon, Function()? onAction, bool? success, String? actionText}) {
|
||||||
|
|
||||||
OneContext().hideCurrentSnackBar();
|
BuildContext? context = OneContext().context;
|
||||||
|
|
||||||
|
if (context != null) {
|
||||||
|
ScaffoldMessenger.of(context).hideCurrentSnackBar();
|
||||||
|
}
|
||||||
|
|
||||||
Color backgroundColor = Colors.deepOrange;
|
Color backgroundColor = Colors.deepOrange;
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class Spinner extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _SpinnerState extends State<Spinner> with SingleTickerProviderStateMixin {
|
class _SpinnerState extends State<Spinner> with SingleTickerProviderStateMixin {
|
||||||
AnimationController? _controller;
|
late AnimationController? _controller;
|
||||||
Widget? _child;
|
Widget? _child;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -71,7 +71,7 @@ class _StarredPartState extends RefreshableState<StarredPartWidget> {
|
|||||||
return progressIndicator();
|
return progressIndicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (starredParts.length == 0) {
|
if (starredParts.isEmpty) {
|
||||||
return ListView(
|
return ListView(
|
||||||
children: [
|
children: [
|
||||||
ListTile(
|
ListTile(
|
||||||
|
@ -142,7 +142,7 @@ class _StockItemTestResultDisplayState extends RefreshableState<StockItemTestRes
|
|||||||
|
|
||||||
var results = getTestResults();
|
var results = getTestResults();
|
||||||
|
|
||||||
if (results.length == 0) {
|
if (results.isEmpty) {
|
||||||
tiles.add(ListTile(
|
tiles.add(ListTile(
|
||||||
title: Text(L10().testResultNone),
|
title: Text(L10().testResultNone),
|
||||||
subtitle: Text(L10().testResultNoneDetail),
|
subtitle: Text(L10().testResultNoneDetail),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user