From b1e5e73278c39bf1416f5b365ef2fad7e775610c Mon Sep 17 00:00:00 2001 From: Yegor Vialov Date: Mon, 25 May 2020 08:52:16 +0000 Subject: [PATCH] Fix display name getting issue --- lib/entities/entity.class.dart | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/entities/entity.class.dart b/lib/entities/entity.class.dart index c203bd7..19833d4 100644 --- a/lib/entities/entity.class.dart +++ b/lib/entities/entity.class.dart @@ -78,9 +78,21 @@ class Entity { chartType: EntityHistoryWidgetType.simple ); - String get displayName => - attributes["friendly_name"] ?? - (attributes["name"] ?? (entityId != null && entityId.contains('.')) ? entityId.split(".")[1].replaceAll("_", " ") : ""); + String get displayName { + if (attributes.containsKey('friendly_name')) { + return attributes['friendly_name']; + } + if (attributes.containsKey('name')) { + return attributes['name']; + } + if (entityId == null) { + return ""; + } + if (entityId.contains(".")) { + return entityId.split(".")[1].replaceAll("_", " "); + } + return entityId; + } bool get isView => (domain == "group") &&