Skip to content

Commit

Permalink
Refactor DashTool.fromLabel
Browse files Browse the repository at this point in the history
  • Loading branch information
eliasyishak committed Mar 29, 2024
1 parent b412b59 commit e1d45d5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkgs/unified_analytics/lib/src/enums.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,8 @@ enum DashTool {
/// This takes in the string label for a given [DashTool] and returns the
/// enum for that string label.
static DashTool fromLabel(String label) {
for (final tool in DashTool.values) {
if (tool.label == label) return tool;
}
final tool = DashTool.values.where((t) => t.label == label).firstOrNull;
if (tool != null) return tool;

throw Exception('The tool $label from the survey metadata file is not '
'a valid DashTool enum value\n'
Expand Down

0 comments on commit e1d45d5

Please sign in to comment.