@@ -112,6 +112,7 @@ class Showcase extends StatefulWidget {
112112 this .enableAutoScroll,
113113 this .floatingActionWidget,
114114 this .targetTooltipGap = 10 ,
115+ this .scope,
115116 }) : container = null ,
116117 showcaseKey = key,
117118 assert (
@@ -201,6 +202,7 @@ class Showcase extends StatefulWidget {
201202 this .enableAutoScroll,
202203 this .toolTipMargin = 14 ,
203204 this .targetTooltipGap = 10 ,
205+ this .scope,
204206 }) : showArrow = false ,
205207 onToolTipClick = null ,
206208 scaleAnimationDuration = const Duration (milliseconds: 300 ),
@@ -258,6 +260,11 @@ class Showcase extends StatefulWidget {
258260 /// target widget while showcasing.
259261 final GlobalKey showcaseKey;
260262
263+ /// Optional scope name for this showcase widget.
264+ /// If provided, this widget will be registered under the specified scope
265+ /// instead of the current active scope.
266+ final String ? scope;
267+
261268 /// Target widget that will be showcased or highlighted
262269 final Widget child;
263270
@@ -527,6 +534,10 @@ class Showcase extends StatefulWidget {
527534}
528535
529536class _ShowcaseState extends State <Showcase > {
537+ /// Returns the scope name for this Showcase instance.
538+ late final String _scopeName =
539+ widget.scope ?? ShowcaseService .instance.getScope ().name;
540+
530541 ShowcaseController get _controller => ShowcaseService .instance.getController (
531542 key: widget.showcaseKey,
532543 id: _uniqueId,
@@ -540,7 +551,8 @@ class _ShowcaseState extends State<Showcase> {
540551 @override
541552 void initState () {
542553 super .initState ();
543- _showCaseWidgetManager = ShowcaseService .instance.getScope ();
554+ _showCaseWidgetManager =
555+ ShowcaseService .instance.getScope (scope: _scopeName);
544556 ShowcaseController .register (
545557 id: _uniqueId,
546558 key: widget.showcaseKey,
@@ -603,17 +615,15 @@ class _ShowcaseState extends State<Showcase> {
603615 }
604616
605617 void _updateControllerValues () {
606- final manager = ShowcaseService .instance.getScope (
607- scope: _showCaseWidgetManager.name,
608- );
618+ final manager = ShowcaseService .instance.getScope (scope: _scopeName);
609619 if (manager == _showCaseWidgetManager) return ;
610620 _showCaseWidgetManager = manager;
611621 ShowcaseService .instance.addController (
612622 controller: _controller
613623 ..showcaseView = _showCaseWidgetManager.showcaseView,
614624 key: widget.showcaseKey,
615625 id: _uniqueId,
616- scope: _showCaseWidgetManager.name ,
626+ scope: _scopeName ,
617627 );
618628 }
619629}
0 commit comments