Skip to content

Commit a6afbc0

Browse files
committed
refactor(headline-details): improve chip creation in _HeadlineDetailsPageState
- Use cascade notation to add chips, making the code more concise - Maintain the original functionality and design of the chips - Enhance readability by organizing chip creation in a more structured way
1 parent 8458a9f commit a6afbc0

File tree

1 file changed

+54
-55
lines changed

1 file changed

+54
-55
lines changed

lib/headline-details/view/headline_details_page.dart

Lines changed: 54 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -402,74 +402,73 @@ class _HeadlineDetailsPageState extends State<HeadlineDetailsPage> {
402402
final chips = <Widget>[];
403403

404404
final formattedDate = DateFormat('MMM d, yyyy').format(headline.createdAt);
405-
chips.add(
406-
Chip(
407-
avatar: Icon(
408-
Icons.calendar_today_outlined,
409-
size: chipAvatarSize,
410-
color: chipAvatarColor,
411-
),
412-
label: Text(formattedDate),
413-
labelStyle: chipLabelStyle,
414-
backgroundColor: chipBackgroundColor,
415-
padding: chipPadding,
416-
shape: chipShape,
417-
visualDensity: VisualDensity.compact,
418-
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
419-
),
420-
);
421-
422-
chips.add(
423-
InkWell(
424-
onTap: () {
425-
context.push(
426-
Routes.sourceDetails,
427-
extra: EntityDetailsPageArguments(entity: headline.source),
428-
);
429-
},
430-
borderRadius: BorderRadius.circular(AppSpacing.sm),
431-
child: Chip(
405+
chips
406+
..add(
407+
Chip(
432408
avatar: Icon(
433-
Icons.source_outlined,
409+
Icons.calendar_today_outlined,
434410
size: chipAvatarSize,
435411
color: chipAvatarColor,
436412
),
437-
label: Text(headline.source.name),
413+
label: Text(formattedDate),
438414
labelStyle: chipLabelStyle,
439415
backgroundColor: chipBackgroundColor,
440416
padding: chipPadding,
441417
shape: chipShape,
442418
visualDensity: VisualDensity.compact,
443419
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
444420
),
445-
),
446-
);
447-
448-
chips.add(
449-
InkWell(
450-
onTap: () {
451-
context.push(
452-
Routes.topicDetails,
453-
extra: EntityDetailsPageArguments(entity: headline.topic),
454-
);
455-
},
456-
borderRadius: BorderRadius.circular(AppSpacing.sm),
457-
child: Chip(
458-
avatar: Icon(
459-
Icons.category_outlined,
460-
size: chipAvatarSize,
461-
color: chipAvatarColor,
421+
)
422+
..add(
423+
InkWell(
424+
onTap: () {
425+
context.push(
426+
Routes.sourceDetails,
427+
extra: EntityDetailsPageArguments(entity: headline.source),
428+
);
429+
},
430+
borderRadius: BorderRadius.circular(AppSpacing.sm),
431+
child: Chip(
432+
avatar: Icon(
433+
Icons.source_outlined,
434+
size: chipAvatarSize,
435+
color: chipAvatarColor,
436+
),
437+
label: Text(headline.source.name),
438+
labelStyle: chipLabelStyle,
439+
backgroundColor: chipBackgroundColor,
440+
padding: chipPadding,
441+
shape: chipShape,
442+
visualDensity: VisualDensity.compact,
443+
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
462444
),
463-
label: Text(headline.topic.name),
464-
labelStyle: chipLabelStyle,
465-
backgroundColor: chipBackgroundColor,
466-
padding: chipPadding,
467-
shape: chipShape,
468-
visualDensity: VisualDensity.compact,
469-
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
470445
),
471-
),
472-
);
446+
)
447+
..add(
448+
InkWell(
449+
onTap: () {
450+
context.push(
451+
Routes.topicDetails,
452+
extra: EntityDetailsPageArguments(entity: headline.topic),
453+
);
454+
},
455+
borderRadius: BorderRadius.circular(AppSpacing.sm),
456+
child: Chip(
457+
avatar: Icon(
458+
Icons.category_outlined,
459+
size: chipAvatarSize,
460+
color: chipAvatarColor,
461+
),
462+
label: Text(headline.topic.name),
463+
labelStyle: chipLabelStyle,
464+
backgroundColor: chipBackgroundColor,
465+
padding: chipPadding,
466+
shape: chipShape,
467+
visualDensity: VisualDensity.compact,
468+
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
469+
),
470+
),
471+
);
473472

474473
return chips;
475474
}

0 commit comments

Comments
 (0)