Skip to content

Commit 9fa045e

Browse files
committed
refactor(entity_details): improve content action handling
- Replace if-else statement with switch expression for contentType - Simplify action assignment using switch expression - Add default case to return null for unknown contentType values - Move return statement outside of switch expression
1 parent 5abe9ea commit 9fa045e

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/entity_details/view/entity_details_page.dart

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,15 @@ class _EntityDetailsViewState extends State<EntityDetailsView> {
180180

181181
if (contentType == null) return;
182182

183-
final ContentAction action;
184-
switch (contentType) {
185-
case ContentType.topic:
186-
action = ContentAction.followTopic;
187-
case ContentType.source:
188-
action = ContentAction.followSource;
189-
case ContentType.country:
190-
action = ContentAction.followCountry;
191-
case ContentType.headline:
192-
return;
183+
final action = switch (contentType) {
184+
ContentType.topic => ContentAction.followTopic,
185+
ContentType.source => ContentAction.followSource,
186+
ContentType.country => ContentAction.followCountry,
187+
_ => null,
188+
};
189+
190+
if (action == null) {
191+
return;
193192
}
194193

195194
final status = limitationService.checkAction(action);

0 commit comments

Comments
 (0)