11import 'package:fluent_ui/fluent_ui.dart' ;
22import 'package:flutter/rendering.dart' ;
33
4+ /// The alignment of the chevron icon in the breadcrumb bar.
5+ enum ChevronAlignment {
6+ /// The chevron icon is aligned to the top of the item.
7+ top,
8+
9+ /// The chevron icon is aligned to the center of the item.
10+ ///
11+ /// This is the default value.
12+ center,
13+
14+ /// The chevron icon is aligned to the bottom of the item.
15+ bottom;
16+
17+ CrossAxisAlignment get crossAxisAlignment {
18+ switch (this ) {
19+ case ChevronAlignment .top:
20+ return CrossAxisAlignment .start;
21+ case ChevronAlignment .center:
22+ return CrossAxisAlignment .center;
23+ case ChevronAlignment .bottom:
24+ return CrossAxisAlignment .end;
25+ }
26+ }
27+ }
28+
429typedef ChevronIconBuilder <T > = Widget Function (
530 BuildContext context,
631 int index,
@@ -96,6 +121,11 @@ class BreadcrumbBar<T> extends StatefulWidget {
96121 /// Defaults to 8.0
97122 final double chevronIconSize;
98123
124+ /// The alignment of the chevron icon.
125+ ///
126+ /// Defaults to [ChevronAlignment.center] .
127+ final ChevronAlignment chevronAlignment;
128+
99129 /// Creates a breadcrumb bar.
100130 const BreadcrumbBar ({
101131 super .key,
@@ -104,28 +134,32 @@ class BreadcrumbBar<T> extends StatefulWidget {
104134 this .onItemPressed,
105135 this .chevronIconBuilder = _defaultChevronBuilder,
106136 this .chevronIconSize = 8.0 ,
137+ this .chevronAlignment = ChevronAlignment .center,
107138 });
108139
109140 /// The default overflow button builder.
110141 static Widget _defaultOverflowButtonBuilder (
111142 BuildContext context,
112143 VoidCallback openFlyout,
113144 ) {
114- return HoverButton (
115- margin: const EdgeInsetsDirectional .symmetric (horizontal: 4.0 ),
116- onPressed: openFlyout,
117- builder: (context, states) {
118- final foregroundColor = ButtonThemeData .buttonForegroundColor (
119- context,
120- states,
121- );
145+ return ConstrainedBox (
146+ constraints: const BoxConstraints (minHeight: 19.0 ),
147+ child: HoverButton (
148+ margin: const EdgeInsetsDirectional .symmetric (horizontal: 4.0 ),
149+ onPressed: openFlyout,
150+ builder: (context, states) {
151+ final foregroundColor = ButtonThemeData .buttonForegroundColor (
152+ context,
153+ states,
154+ );
122155
123- return Icon (
124- FluentIcons .more,
125- color: foregroundColor,
126- size: 12.0 ,
127- );
128- },
156+ return Icon (
157+ FluentIcons .more,
158+ color: foregroundColor,
159+ size: 12.0 ,
160+ );
161+ },
162+ ),
129163 );
130164 }
131165
@@ -211,16 +245,20 @@ class BreadcrumbBarState<T> extends State<BreadcrumbBar<T>> {
211245 return items.indexOf (widget.items[index]);
212246 }).toSet ();
213247 },
214- overflowButton: Row (mainAxisSize: MainAxisSize .min, children: [
215- FlyoutTarget (
216- controller: flyoutController,
217- child: widget.overflowButtonBuilder (context, showFlyout),
218- ),
219- IconTheme .merge (
220- data: IconThemeData (size: widget.chevronIconSize),
221- child: widget.chevronIconBuilder (context, - 1 ),
222- ),
223- ]),
248+ overflowButton: Row (
249+ mainAxisSize: MainAxisSize .min,
250+ crossAxisAlignment: widget.chevronAlignment.crossAxisAlignment,
251+ children: [
252+ FlyoutTarget (
253+ controller: flyoutController,
254+ child: widget.overflowButtonBuilder (context, showFlyout),
255+ ),
256+ IconTheme .merge (
257+ data: IconThemeData (size: widget.chevronIconSize),
258+ child: widget.chevronIconBuilder (context, - 1 ),
259+ ),
260+ ],
261+ ),
224262 children: List .generate (items.length, (index) {
225263 final item = items[index];
226264
@@ -250,13 +288,17 @@ class BreadcrumbBarState<T> extends State<BreadcrumbBar<T>> {
250288 final isLastItem = isReversed ? index == 0 : index == items.length - 1 ;
251289 if (isLastItem) return label;
252290
253- return Row (mainAxisSize: MainAxisSize .min, children: [
254- label,
255- IconTheme .merge (
256- data: IconThemeData (size: widget.chevronIconSize),
257- child: widget.chevronIconBuilder (context, index),
258- ),
259- ]);
291+ return Row (
292+ mainAxisSize: MainAxisSize .min,
293+ crossAxisAlignment: widget.chevronAlignment.crossAxisAlignment,
294+ children: [
295+ label,
296+ IconTheme .merge (
297+ data: IconThemeData (size: widget.chevronIconSize),
298+ child: widget.chevronIconBuilder (context, index),
299+ ),
300+ ],
301+ );
260302 }),
261303 );
262304 }
0 commit comments