@@ -334,8 +334,10 @@ class _TabViewState extends State<TabView> {
334334
335335 @override
336336 Widget build (BuildContext context) {
337+ assert (debugCheckHasDirectionality (context));
337338 assert (debugCheckHasFluentTheme (context));
338339 assert (debugCheckHasFluentLocalizations (context));
340+ final TextDirection direction = Directionality .of (context);
339341 final ThemeData theme = FluentTheme .of (context);
340342 final localizations = FluentLocalizations .of (context);
341343
@@ -414,35 +416,51 @@ class _TabViewState extends State<TabView> {
414416 bool scrollable = preferredTabWidth * widget.tabs.length >
415417 width - (widget.showNewButton ? _kButtonWidth : 0 );
416418
419+ final bool showScrollButtons =
420+ widget.showScrollButtons && scrollable;
421+ final backwardButton = _buttonTabBuilder (
422+ context,
423+ const Icon (FluentIcons .caret_left_solid8, size: 10 ),
424+ ! scrollController.canBackward
425+ ? () {
426+ if (direction == TextDirection .ltr) {
427+ scrollController.backward ();
428+ } else {
429+ scrollController.forward ();
430+ }
431+ }
432+ : null ,
433+ localizations.scrollTabBackwardLabel,
434+ );
435+
436+ final forwardButton = _buttonTabBuilder (
437+ context,
438+ const Icon (FluentIcons .caret_right_solid8, size: 10 ),
439+ ! scrollController.canForward
440+ ? () {
441+ if (direction == TextDirection .ltr) {
442+ scrollController.forward ();
443+ } else {
444+ scrollController.backward ();
445+ }
446+ }
447+ : null ,
448+ localizations.scrollTabForwardLabel,
449+ );
450+
417451 return Row (children: [
418- if (widget.showScrollButtons && scrollable)
419- _buttonTabBuilder (
420- context,
421- const Icon (FluentIcons .caret_left_solid8, size: 10 ),
422- ! scrollController.canBackward
423- ? () {
424- scrollController.backward ();
425- }
426- : null ,
427- localizations.scrollTabBackwardLabel,
428- ),
452+ if (showScrollButtons)
453+ direction == TextDirection .ltr
454+ ? backwardButton
455+ : forwardButton,
429456 if (scrollable)
430457 Expanded (child: listView)
431458 else
432- Flexible (
433- child: listView,
434- ),
435- if (widget.showScrollButtons && scrollable)
436- _buttonTabBuilder (
437- context,
438- const Icon (FluentIcons .caret_right_solid8, size: 10 ),
439- ! scrollController.canForward
440- ? () {
441- scrollController.forward ();
442- }
443- : null ,
444- localizations.scrollTabForwardLabel,
445- ),
459+ Flexible (child: listView),
460+ if (showScrollButtons)
461+ direction == TextDirection .ltr
462+ ? forwardButton
463+ : backwardButton,
446464 if (widget.showNewButton)
447465 _buttonTabBuilder (
448466 context,
@@ -522,15 +540,18 @@ class _TabViewState extends State<TabView> {
522540}
523541
524542class Tab {
543+ /// Creates a tab.
525544 const Tab ({
526- Key ? key,
545+ this . key,
527546 this .icon = const FlutterLogo (),
528547 required this .text,
529548 this .closeIcon = FluentIcons .chrome_close,
530549 this .onClosed,
531550 this .semanticLabel,
532551 });
533552
553+ final Key ? key;
554+
534555 /// The leading icon of the tab. [FlutterLogo] is used by default
535556 final Widget ? icon;
536557
@@ -617,6 +638,7 @@ class __TabState extends State<_Tab>
617638 }
618639 }();
619640 return HoverButton (
641+ key: widget.tab.key,
620642 semanticLabel: widget.tab.semanticLabel ?? text,
621643 focusNode: widget.focusNode,
622644 onPressed: widget.onPressed,
0 commit comments