More linting work

This commit is contained in:
Oliver 2021-09-28 20:24:55 +10:00
parent c1152ee286
commit ad0cc36540
50 changed files with 904 additions and 907 deletions

View file

@ -1,12 +1,12 @@
import 'package:inventree/api.dart';
import 'package:inventree/inventree/stock.dart';
import 'package:inventree/inventree/company.dart';
import 'package:flutter/cupertino.dart';
import 'package:inventree/l10.dart';
import "dart:io";
import 'model.dart';
import 'dart:io';
import 'package:http/http.dart' as http;
import "package:inventree/api.dart";
import "package:inventree/inventree/stock.dart";
import "package:inventree/inventree/company.dart";
import "package:flutter/cupertino.dart";
import "package:inventree/l10.dart";
import "model.dart";
class InvenTreePartCategory extends InvenTreeModel {
@ -33,7 +33,7 @@ class InvenTreePartCategory extends InvenTreeModel {
return filters;
}
String get pathstring => (jsondata['pathstring'] ?? '') as String;
String get pathstring => (jsondata["pathstring"] ?? "") as String;
String get parentpathstring {
// TODO - Drive the refactor tractor through this
@ -52,7 +52,7 @@ class InvenTreePartCategory extends InvenTreeModel {
return p;
}
int get partcount => (jsondata['parts'] ?? 0) as int;
int get partcount => (jsondata["parts"] ?? 0) as int;
InvenTreePartCategory() : super();
@ -74,17 +74,15 @@ class InvenTreePartTestTemplate extends InvenTreeModel {
@override
String get URL => "part/test-template/";
String get key => (jsondata['key'] ?? '') as String;
String get key => (jsondata["key"] ?? "") as String;
String get testName => (jsondata['test_name'] ?? '') as String;
String get testName => (jsondata["test_name"] ?? "") as String;
String get description => (jsondata['description'] ?? '') as String;
bool get required => (jsondata["required"] ?? false) as bool;
bool get required => (jsondata['required'] ?? false) as bool;
bool get requiresValue => (jsondata["requires_value"] ?? false) as bool;
bool get requiresValue => (jsondata['requires_value'] ?? false) as bool;
bool get requiresAttachment => (jsondata['requires_attachment'] ?? false) as bool;
bool get requiresAttachment => (jsondata["requires_attachment"] ?? false) as bool;
InvenTreePartTestTemplate() : super();
@ -195,7 +193,7 @@ class InvenTreePart extends InvenTreeModel {
});
}
int get supplierCount => (jsondata['suppliers'] ?? 0) as int;
int get supplierCount => (jsondata["suppliers"] ?? 0) as int;
// Request supplier parts for this part
Future<List<InvenTreeSupplierPart>> getSupplierParts() async {
@ -242,7 +240,7 @@ class InvenTreePart extends InvenTreeModel {
}
// Get the number of stock on order for this Part
double get onOrder => double.tryParse(jsondata['ordering'].toString()) ?? 0;
double get onOrder => double.tryParse(jsondata["ordering"].toString()) ?? 0;
String get onOrderString {
@ -254,7 +252,7 @@ class InvenTreePart extends InvenTreeModel {
}
// Get the stock count for this Part
double get inStock => double.tryParse(jsondata['in_stock'].toString()) ?? 0;
double get inStock => double.tryParse(jsondata["in_stock"].toString()) ?? 0;
String get inStockString {
@ -271,69 +269,69 @@ class InvenTreePart extends InvenTreeModel {
return q;
}
String get units => (jsondata["units"] as String) ?? "";
String get units => (jsondata["units"] ?? "") as String;
// Get the number of units being build for this Part
double get building => double.tryParse(jsondata['building'].toString()) ?? 0;
double get building => double.tryParse(jsondata["building"].toString()) ?? 0;
// Get the number of BOM items in this Part (if it is an assembly)
int get bomItemCount => (jsondata['bom_items'] ?? 0) as int;
int get bomItemCount => (jsondata["bom_items"] ?? 0) as int;
// Get the number of BOMs this Part is used in (if it is a component)
int get usedInCount => (jsondata['used_in'] ?? 0) as int;
int get usedInCount => (jsondata["used_in"] ?? 0) as int;
bool get isAssembly => (jsondata['assembly'] ?? false) as bool;
bool get isAssembly => (jsondata["assembly"] ?? false) as bool;
bool get isComponent => (jsondata['component'] ?? false) as bool;
bool get isComponent => (jsondata["component"] ?? false) as bool;
bool get isPurchaseable => (jsondata['purchaseable'] ?? false) as bool;
bool get isPurchaseable => (jsondata["purchaseable"] ?? false) as bool;
bool get isSalable => (jsondata['salable'] ?? false) as bool;
bool get isSalable => (jsondata["salable"] ?? false) as bool;
bool get isActive => (jsondata['active'] ?? false) as bool;
bool get isActive => (jsondata["active"] ?? false) as bool;
bool get isVirtual => (jsondata['virtual'] ?? false) as bool;
bool get isVirtual => (jsondata["virtual"] ?? false) as bool;
bool get isTrackable => (jsondata['trackable'] ?? false) as bool;
bool get isTrackable => (jsondata["trackable"] ?? false) as bool;
// Get the IPN (internal part number) for the Part instance
String get IPN => (jsondata['IPN'] ?? '') as String;
String get IPN => (jsondata["IPN"] ?? "") as String;
// Get the revision string for the Part instance
String get revision => (jsondata['revision'] ?? '') as String;
String get revision => (jsondata["revision"] ?? "") as String;
// Get the category ID for the Part instance (or 'null' if does not exist)
int get categoryId => (jsondata['category'] ?? -1) as int;
// Get the category ID for the Part instance (or "null" if does not exist)
int get categoryId => (jsondata["category"] ?? -1) as int;
// Get the category name for the Part instance
String get categoryName {
// Inavlid category ID
if (categoryId <= 0) return '';
if (categoryId <= 0) return "";
if (!jsondata.containsKey('category_detail')) return '';
if (!jsondata.containsKey("category_detail")) return "";
return (jsondata['category_detail']?['name'] ?? '') as String;
return (jsondata["category_detail"]?["name"] ?? "") as String;
}
// Get the category description for the Part instance
String get categoryDescription {
// Invalid category ID
if (categoryId <= 0) return '';
if (categoryId <= 0) return "";
if (!jsondata.containsKey('category_detail')) return '';
if (!jsondata.containsKey("category_detail")) return "";
return (jsondata['category_detail']?['description'] ?? '') as String;
return (jsondata["category_detail"]?["description"] ?? "") as String;
}
// Get the image URL for the Part instance
String get _image => (jsondata['image'] ?? '') as String;
String get _image => (jsondata["image"] ?? "") as String;
// Get the thumbnail URL for the Part instance
String get _thumbnail => (jsondata['thumbnail'] ?? '') as String;
String get _thumbnail => (jsondata["thumbnail"] ?? "") as String;
// Return the fully-qualified name for the Part instance
String get fullname {
String fn = (jsondata['full_name'] ?? '') as String;
String fn = (jsondata["full_name"] ?? "") as String;
if (fn.isNotEmpty) return fn;
@ -369,15 +367,15 @@ class InvenTreePart extends InvenTreeModel {
final APIResponse response = await InvenTreeAPI().uploadFile(
url,
image,
method: 'PATCH',
name: 'image',
method: "PATCH",
name: "image",
);
return response.successful();
}
// Return the "starred" status of this part
bool get starred => (jsondata['starred'] ?? false) as bool;
bool get starred => (jsondata["starred"] ?? false) as bool;
InvenTreePart() : super();