2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-05-02 23:38:54 +00:00

Fix null ptr errors

This commit is contained in:
Oliver Walters 2021-02-16 23:24:10 +11:00
parent 911f988fa5
commit 33483eb9e1
2 changed files with 53 additions and 20 deletions

View File

@ -40,22 +40,40 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
@override
List<Widget> getAppBarActions(BuildContext context) {
return <Widget>[
IconButton(
List<Widget> actions = [];
actions.add(
IconButton(
icon: FaIcon(FontAwesomeIcons.search),
onPressed: () {
Map<String, String> filters = {};
if (category != null) {
filters["category"] = "${category.pk}";
}
showSearch(
context: context,
delegate: PartSearchDelegate(context, filters: {"category": "${category.pk}"})
delegate: PartSearchDelegate(context, filters: filters)
);
}
),
IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
tooltip: I18N.of(context).edit,
onPressed: _editCategoryDialog,
),
];
)
);
if (category != null) {
actions.add(
IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
tooltip: I18N.of(context).edit,
onPressed: _editCategoryDialog,
)
);
}
return actions;
}
void _editCategory(Map<String, String> values) async {
@ -63,7 +81,6 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
final bool result = await category.update(context, values: values);
showSnackIcon(
refreshableKey,
result ? "Category edited" : "Category editing failed",
success: result
);

View File

@ -39,22 +39,39 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
@override
List<Widget> getAppBarActions(BuildContext context) {
return <Widget>[
List<Widget> actions = [];
actions.add(
IconButton(
icon: FaIcon(FontAwesomeIcons.search),
onPressed: () {
Map<String, String> filters = {};
if (location != null) {
filters["location"] = "${location.pk}";
}
showSearch(
context: context,
delegate: StockSearchDelegate(context, filters: {"location": "${location.pk}"})
delegate: StockSearchDelegate(context, filters: filters)
);
}
),
IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
tooltip: I18N.of(context).edit,
onPressed: _editLocationDialog,
)
];
);
if (location != null) {
actions.add(
IconButton(
icon: FaIcon(FontAwesomeIcons.edit),
tooltip: I18N.of(context).edit,
onPressed: _editLocationDialog,
)
);
}
return actions;
}
void _editLocation(Map<String, String> values) async {
@ -62,7 +79,6 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
final bool result = await location.update(context, values: values);
showSnackIcon(
refreshableKey,
result ? "Location edited" : "Location editing failed",
success: result
);