build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Builds the expandable SliverStickyHeader using MutablePylon for state and SliverAnimatedPaintExtent for smooth expansion animations.

The header is a tappable GhostButton wrapping a Bar that toggles expansion state, updating the chevron icon and visibility of the sliver content. Integrates with ArcaneTheme for sidebar-aware layout and uses SliverVisibility to conditionally show/hide the sliver based on the expansion state.

Implementation

@override
Widget build(BuildContext context) => MutablePylon<ExpansionBarState>(
      local: true,
      value: ExpansionBarState(initiallyExpanded),
      builder: (context) {
        Widget icon = context.streamPylon<ExpansionBarState>().buildNullable(
            (state) => (state?.expanded ?? true)
                ? const Icon(Icons.chevron_up_ionic)
                : const Icon(Icons.chevron_down_ionic));

        return SliverStickyHeader.builder(
          builder: (context, state) => GhostButton(
              density: ButtonDensity.compact,
              onPressed: () => context.modPylon<ExpansionBarState>(
                  (i) => ExpansionBarState(!i.expanded)),
              child: Bar(
                ignoreContextSignals: true,
                useGlass: state.isPinned,
                backButton: backButton,
                title: context.isSidebarExpandedOrAbsent ? title : icon,
                header: header,
                subtitle: subtitle,
                titleText: titleText,
                subtitleText: subtitleText,
                headerText: headerText,
                leading: leading,
                trailing: [
                  ...trailing,
                  if (context.isSidebarExpandedOrAbsent) icon
                ],
              )),
          sliver: SliverAnimatedPaintExtent(
              duration: Duration(milliseconds: 333),
              curve: Curves.easeOutCirc,
              child: context
                  .streamPylon<ExpansionBarState>()
                  .buildNullable((state) => SliverVisibility(
                        visible: (state?.expanded ?? true),
                        sliver: sliver,
                      ))),
        );
      },
    );