Skip to content

Commit

Permalink
Customize level titles in DiagnosticLevelSelector
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasWanke committed Nov 7, 2023
1 parent 20ff82d commit 3108197
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/src/utils/level_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DiagnosticLevelSelector extends StatelessWidget {
onSelected: onSelected,
itemBuilder: (context) => [
for (final level in DiagnosticLevel.values)
PopupMenuItem(value: level, child: Text(level.name)),
PopupMenuItem(value: level, child: Text(level.title)),
],
);
}
Expand All @@ -36,3 +36,19 @@ class DiagnosticLevelSelector extends StatelessWidget {
};
}
}

extension on DiagnosticLevel {
String get title {
return switch (this) {
DiagnosticLevel.hidden => 'All',
DiagnosticLevel.fine => '≥ Fine',
DiagnosticLevel.debug => '≥ Debug',
DiagnosticLevel.info => '≥ Info',
DiagnosticLevel.warning => '≥ Warning',
DiagnosticLevel.hint => '≥ Hint',
DiagnosticLevel.summary => '≥ Summary',
DiagnosticLevel.error => '≥ Error',
DiagnosticLevel.off => 'None',
};
}
}

0 comments on commit 3108197

Please sign in to comment.