From 40613c9c3657c84c716dd3f2db52a74c2bdb2911 Mon Sep 17 00:00:00 2001 From: Oliver Date: Tue, 13 Jul 2021 00:13:38 +1000 Subject: [PATCH] .empty() -> [] Turns out .empty() creates an empty list which is fixed length! --- lib/inventree/model.dart | 2 +- lib/inventree/part.dart | 6 +++--- lib/inventree/stock.dart | 4 ++-- lib/settings/login.dart | 2 +- lib/user_profile.dart | 4 ++-- lib/widget/category_display.dart | 2 +- lib/widget/company_detail.dart | 2 +- lib/widget/company_list.dart | 4 ++-- lib/widget/dialogs.dart | 2 +- lib/widget/location_display.dart | 2 +- lib/widget/stock_detail.dart | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/inventree/model.dart b/lib/inventree/model.dart index f0dccd81..2fc5a81f 100644 --- a/lib/inventree/model.dart +++ b/lib/inventree/model.dart @@ -307,7 +307,7 @@ class InvenTreeModel { var response = await api.get(URL, params: params); // A list of "InvenTreeModel" items - List results = new List.empty(); + List results = []; if (response == null) { return results; diff --git a/lib/inventree/part.dart b/lib/inventree/part.dart index 0ec4647a..c0cef5dc 100644 --- a/lib/inventree/part.dart +++ b/lib/inventree/part.dart @@ -149,7 +149,7 @@ class InvenTreePart extends InvenTreeModel { } // Cached list of stock items - List stockItems = List.empty(); + List stockItems = []; int get stockItemCount => stockItems.length; @@ -175,7 +175,7 @@ class InvenTreePart extends InvenTreeModel { int get supplier_count => (jsondata['suppliers'] ?? 0) as int; // Cached list of test templates - List testingTemplates = List.empty(); + List testingTemplates = []; int get testTemplateCount => testingTemplates.length; @@ -277,7 +277,7 @@ class InvenTreePart extends InvenTreeModel { if (fn.isNotEmpty) return fn; - List elements = List.empty(); + List elements = []; if (IPN.isNotEmpty) elements.add(IPN); diff --git a/lib/inventree/stock.dart b/lib/inventree/stock.dart index 84bb531d..d730be74 100644 --- a/lib/inventree/stock.dart +++ b/lib/inventree/stock.dart @@ -138,7 +138,7 @@ class InvenTreeStockItem extends InvenTreeModel { // TODO } - List testTemplates = List.empty(); + List testTemplates = []; int get testTemplateCount => testTemplates.length; @@ -159,7 +159,7 @@ class InvenTreeStockItem extends InvenTreeModel { }); } - List testResults = List.empty(); + List testResults = []; int get testResultCount => testResults.length; diff --git a/lib/settings/login.dart b/lib/settings/login.dart index 20055dee..8dbaf324 100644 --- a/lib/settings/login.dart +++ b/lib/settings/login.dart @@ -26,7 +26,7 @@ class _InvenTreeLoginSettingsState extends State { final GlobalKey _addProfileKey = new GlobalKey(); - List profiles = new List.empty(); + List profiles = []; _InvenTreeLoginSettingsState() { _reload(); diff --git a/lib/user_profile.dart b/lib/user_profile.dart index 067db1f3..efbd81ca 100644 --- a/lib/user_profile.dart +++ b/lib/user_profile.dart @@ -133,7 +133,7 @@ class UserProfileDBManager { final profiles = await store.find(await _db); - List profileList = new List.empty(); + List profileList = []; for (int idx = 0; idx < profiles.length; idx++) { @@ -158,7 +158,7 @@ class UserProfileDBManager { final profiles = await store.find(await _db); - List profileList = new List.empty(); + List profileList = []; for (int idx = 0; idx < profiles.length; idx++) { diff --git a/lib/widget/category_display.dart b/lib/widget/category_display.dart index ba459957..d8b74e60 100644 --- a/lib/widget/category_display.dart +++ b/lib/widget/category_display.dart @@ -130,7 +130,7 @@ class _CategoryDisplayState extends RefreshableState { // The local InvenTreePartCategory object final InvenTreePartCategory? category; - List _subcategories = List.empty(); + List _subcategories = []; @override Future onBuild(BuildContext context) async { diff --git a/lib/widget/company_detail.dart b/lib/widget/company_detail.dart index 0de3e249..04134783 100644 --- a/lib/widget/company_detail.dart +++ b/lib/widget/company_detail.dart @@ -107,7 +107,7 @@ class _CompanyDetailState extends RefreshableState { List _companyTiles() { - var tiles = List.empty(); + List tiles = []; bool sep = false; diff --git a/lib/widget/company_list.dart b/lib/widget/company_list.dart index 40be988d..56fc76af 100644 --- a/lib/widget/company_list.dart +++ b/lib/widget/company_list.dart @@ -39,9 +39,9 @@ class CustomerListWidget extends CompanyListWidget { class _CompanyListState extends RefreshableState { - var _companies = new List.empty(); + List _companies = []; - var _filteredCompanies = new List.empty(); + List _filteredCompanies = []; String _title = "Companies"; diff --git a/lib/widget/dialogs.dart b/lib/widget/dialogs.dart index 24345196..8cf13f6d 100644 --- a/lib/widget/dialogs.dart +++ b/lib/widget/dialogs.dart @@ -220,7 +220,7 @@ void showFormDialog(String title, {String? acceptText, String? cancelText, Globa ]; } - var _fields = fields ?? List.empty(); + List _fields = fields ?? []; OneContext().showDialog( builder: (BuildContext context) { diff --git a/lib/widget/location_display.dart b/lib/widget/location_display.dart index 6c2b8e36..94404cee 100644 --- a/lib/widget/location_display.dart +++ b/lib/widget/location_display.dart @@ -128,7 +128,7 @@ class _LocationDisplayState extends RefreshableState { _LocationDisplayState(this.location) {} - List _sublocations = List.empty(); + List _sublocations = []; String _locationFilter = ''; diff --git a/lib/widget/stock_detail.dart b/lib/widget/stock_detail.dart index 17451f39..1682968b 100644 --- a/lib/widget/stock_detail.dart +++ b/lib/widget/stock_detail.dart @@ -296,7 +296,7 @@ class _StockItemDisplayState extends RefreshableState { ) ), suggestionsCallback: (pattern) async { - var suggestions = List.empty(); + List suggestions = []; for (var loc in locations) { if (loc.matchAgainstString(pattern)) {