Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/src/showcase/showcase_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,16 @@ class ShowcaseView {
_onComplete().then(
(_) {
if (!_mounted) return;
// Update active widget ID before starting the next showcase
_activeWidgetId = id;

if (_activeWidgetId! >= _ids!.length) {
_cleanupAfterSteps();
onFinish?.call();
} else {
_onStart();
// Add a short delay before starting the next showcase to ensure proper state update
// Then start the new showcase
Future.microtask(_onStart);
}
},
);
Expand Down Expand Up @@ -414,15 +417,17 @@ class ShowcaseView {
if (controllerLength == 1 && isAutoScroll) {
await firstController?.scrollIntoView();
} else {
// Setup showcases after data is updated
for (var i = 0; i < controllerLength; i++) {
controllers[i].setupShowcase(shouldUpdateOverlay: i == 0);
}
}
}

// Cancel any existing timer before setting up a new one

if (autoPlay) {
_cancelTimer();
// Showcase is first.
final config = _getCurrentActiveControllers.firstOrNull?.config;
_timer = Timer(
config?.autoPlayDelay ?? autoPlayDelay,
Expand Down
19 changes: 19 additions & 0 deletions lib/src/tooltip/arrow_painter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@
*/
part of 'tooltip.dart';

class ShowcaseArrow extends StatelessWidget {
const ShowcaseArrow({
super.key,
required this.strokeColor,
});

final Color strokeColor;

@override
Widget build(BuildContext context) {
return CustomPaint(
painter: _ArrowPainter(
strokeColor: strokeColor,
),
size: const Size(Constants.arrowWidth, Constants.arrowHeight),
);
}
}

class _ArrowPainter extends CustomPainter {
_ArrowPainter({
this.strokeColor = Colors.black,
Expand Down
30 changes: 6 additions & 24 deletions lib/src/tooltip/tooltip_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
: SystemMouseCursors.click,
child: GestureDetector(
onTap: widget.onTooltipTap,
child: Center(child: widget.container ?? const SizedBox.shrink()),
child: widget.container ?? const SizedBox.shrink(),
),
)
: MouseRegion(
Expand All @@ -183,7 +183,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
child: GestureDetector(
onTap: widget.onTooltipTap,
child: Container(
padding: widget.tooltipPadding.copyWith(left: 0, right: 0),
padding: widget.tooltipPadding,
decoration: BoxDecoration(
color: widget.tooltipBackgroundColor,
borderRadius: widget.tooltipBorderRadius ??
Expand All @@ -194,12 +194,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
children: <Widget>[
if (widget.title case final title?)
DefaultTooltipTextWidget(
padding: (widget.titlePadding ?? EdgeInsets.zero).add(
EdgeInsets.only(
left: widget.tooltipPadding.left,
right: widget.tooltipPadding.right,
),
),
padding: widget.titlePadding ?? EdgeInsets.zero,
text: title,
textAlign: widget.titleTextAlign,
alignment: widget.titleAlignment,
Expand All @@ -212,13 +207,7 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
),
if (widget.description case final desc?)
DefaultTooltipTextWidget(
padding:
(widget.descriptionPadding ?? EdgeInsets.zero).add(
EdgeInsets.only(
left: widget.tooltipPadding.left,
right: widget.tooltipPadding.right,
),
),
padding: widget.descriptionPadding ?? EdgeInsets.zero,
text: desc,
textAlign: widget.descriptionTextAlign,
alignment: widget.descriptionAlignment,
Expand All @@ -233,10 +222,6 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
widget.tooltipActionConfig.position.isInside)
ActionWidget(
tooltipActionConfig: widget.tooltipActionConfig,
outsidePadding: EdgeInsets.only(
left: widget.tooltipPadding.left,
right: widget.tooltipPadding.right,
),
alignment: widget.tooltipActionConfig.alignment,
crossAxisAlignment:
widget.tooltipActionConfig.crossAxisAlignment,
Expand Down Expand Up @@ -295,11 +280,8 @@ class _ToolTipWidgetState extends State<ToolTipWidget>
if (widget.showArrow)
_TooltipLayoutId(
id: TooltipLayoutSlot.arrow,
child: CustomPaint(
painter: _ArrowPainter(
strokeColor: widget.tooltipBackgroundColor,
),
size: const Size(Constants.arrowWidth, Constants.arrowHeight),
child: ShowcaseArrow(
strokeColor: widget.tooltipBackgroundColor,
),
),
],
Expand Down
7 changes: 6 additions & 1 deletion lib/src/utils/overlay_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class OverlayManager {
ShowcaseService.instance.updateCurrentScope(scope);
}
_shouldShow = show;
_rebuild();
_sync();
}

Expand Down Expand Up @@ -131,6 +130,8 @@ class OverlayManager {
_hide();
} else if (!_isShowing && _shouldShow) {
_show(_getBuilder);
} else {
_rebuild();
}
}

Expand Down Expand Up @@ -177,6 +178,10 @@ class OverlayManager {
);

return Stack(
// This key is used to force rebuild the overlay when needed.
// this key enables `_overlayEntry?.markNeedsBuild();` to detect that
// output of the builder has changed.
key: ValueKey(firstShowcaseConfig.hashCode),
children: [
GestureDetector(
onTap: firstController.handleBarrierTap,
Expand Down