buildComparatorMenuItems method

Iterable<MenuItem> buildComparatorMenuItems(
  1. BuildContext context
)

Implementation

Iterable<MenuItem> buildComparatorMenuItems(BuildContext context) sync* {
  yield* comparators.map((c) => MenuButton(
        autoClose: false,
        onPressed: (_) {
          if (currentComparator == c) {
            setComparator(currentComparator, reversed: !isComparatorReversed);
          } else {
            setComparator(c, reversed: true);
          }
          update();
        },
        trailing: listen.build((_) => currentComparator == c
            ? Row(
                mainAxisSize: MainAxisSize.min,
                children: [
                  const Icon(Icons.check),
                  const Gap(4),
                  isComparatorReversed
                      ? const Icon(Icons.arrow_down)
                      : const Icon(Icons.arrow_up),
                ],
              )
            : const SizedBox.shrink()),
        leading: Icon(c.icon),
        child: Text(c.name),
      ));
}