Skip to content

Conversation

@Sahil-Simform
Copy link
Collaborator

@Sahil-Simform Sahil-Simform commented Mar 19, 2025

Description

  • A feature was added to show multiple showcases at the same time.
  • Added controller to manage showcase functionality
  • Removed inherited widget, setState and key for improvement
  • Shifted overlay to showcase widget to effectively manage overlay for all showcases (Previously every showcase had its own overlay which was loaded whenever showcase was enabled)

Checklist

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

Closes #113

@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch 4 times, most recently from dce2a62 to ce0b324 Compare March 21, 2025 06:21
@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch 5 times, most recently from 93f75e4 to 407aa26 Compare March 25, 2025 09:12
@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch from 407aa26 to c55862f Compare March 25, 2025 09:44
var renderBox = key.currentContext?.findRenderObject() as RenderBox?;

void _getRenderBox() {
final renderBox = context.findRenderObject() as RenderBox?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take the box directly.

borderRadius: BorderRadius.all(Radius.circular(8)),
);

static const Widget defaultProgressIndicator = CircularProgressIndicator(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use adaptive version.

void didUpdateWidget(OverlayBuilder oldWidget) {
super.didUpdateWidget(oldWidget);
WidgetsBinding.instance.addPostFrameCallback((_) => syncWidgetAndOverlay());
if (oldWidget.showOverlay != widget.showOverlay && widget.showOverlay) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please simplify this.

final bool showOverlay;
final WidgetBuilder? overlayBuilder;
final Widget child;
final ValueSetter<VoidCallback> updateOverlay;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please convert this to static method.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When we convert this to a static method, it is causing an error in the showcase view widget, so we are keeping it the same.

Comment on lines 358 to 367
return Container(
alignment: Alignment.center,
decoration: BoxDecoration(
color: overlayColor

//TODO: Update when we remove support for older version
//ignore: deprecated_member_use
.withOpacity(overlayOpacity),
),
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please switch to Align and ColoredBox.

Comment on lines 399 to 401
(_) {
updateOverlay?.call();
},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use expression body. And ensure that this call is needed twice.

}
}

void _stopTimer() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be renamed I believe.

@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch from ef77c3c to f5ea659 Compare March 26, 2025 06:34
@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch from f5ea659 to 228af1d Compare March 27, 2025 05:39
Comment on lines 585 to 595
showcaseController = ShowcaseController(
showcaseId: widget.hashCode,
showcaseKey: widget.showcaseKey,
showcaseConfig: widget,
scrollIntoView: _scrollIntoView,
)..startShowcase = startShowcase;

showCaseWidgetState.registerShowcaseController(
controller: showcaseController,
key: widget.showcaseKey,
);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep single source of truth.

);
showOverlay();
}
showcaseController.showcaseConfig = widget;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see if this is absolutely required.


recalculateRootWidgetSize();

if (enableShowcase) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please invert this condition and return early.

const TooltipActionConfig();
}

void _updateControllerData(BuildContext context) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep functions testable.

Comment on lines 362 to 365
if (!disableBarrierInteraction &&
!firstShowcaseConfig.disableBarrierInteraction) {
next();
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please invert this condition and return early.

Comment on lines 548 to 552
if (_showcaseControllers.containsKey(key)) {
_showcaseControllers[key]!.add(controller);
} else {
_showcaseControllers[key] = [controller];
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please utilise putIfAbsent method.

Comment on lines 498 to 500
final currentControllers =
(_showcaseControllers[getCurrentActiveShowcaseKey] ??
<ShowcaseController>[]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please create a private getter for this.

@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch 7 times, most recently from 14bdf3b to d50a933 Compare March 31, 2025 00:56
@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch from d50a933 to b476dc8 Compare March 31, 2025 04:38
var renderBox = key.currentContext?.findRenderObject() as RenderBox?;
Offset? _boxOffset;

void _getRenderBox() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename this to match the work its doing.

Comment on lines 144 to 146
Widget build(BuildContext context) {
buildOverlay();

return widget.child!;
return widget.child;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make this expression body.

//ignore: deprecated_member_use
.withOpacity(firstShowcaseConfig.overlayOpacity),
child: const Align(
alignment: Alignment.center,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be the default parameter please check and remove if so.

Comment on lines 474 to 475
if (controllers.length == 1 &&
(controllers.first.showcaseConfig.enableAutoScroll ??
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use firstOrNull here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This API has been available since SDK 3.0.0, but our constraints is '>=2.18.0 <4.0.0' so can not use that.
For now added TODO for the same

int showcaseId,
) {
assert(
_showcaseControllers.containsKey(key) &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be avoided.

Comment on lines 606 to 610
showCaseWidgetState
.getControllerForShowcase(
widget.showcaseKey,
_uniqueId,
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the created getter for this.

_globalFloatingActionWidget = showCaseWidgetState
.globalFloatingActionWidget(widget.showcaseKey)
?.call(context);
final size = _controller.rootWidgetSize ?? MediaQuery.sizeOf(context);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please ensure compatibility to the lowest version supported by this package.

Comment on lines 706 to 709
Future<void> _nextIfAny() async {
if (showCaseWidgetState.isShowCaseCompleted) return;

if (timer != null && timer!.isActive) {
if (showCaseWidgetState.enableAutoPlayLock) {
return;
}
timer!.cancel();
} else if (timer != null && !timer!.isActive) {
timer = null;
}
await _reverseAnimateTooltip();
if (showCaseWidgetState.isShowCaseCompleted) return;
showCaseWidgetState.completed(widget.key);
showCaseWidgetState.completed(widget.showcaseKey);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can easily be moved to controller. Please check for other such methods and make the move.

@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch 3 times, most recently from 3c7679d to e2721d8 Compare April 1, 2025 14:44
@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch 2 times, most recently from a70b882 to 01473f3 Compare April 2, 2025 06:46
@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch 9 times, most recently from e99bb01 to 0a6652b Compare April 3, 2025 11:11
@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch from 0a6652b to 9a94177 Compare April 3, 2025 11:14
@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch from 5723af9 to 5405eee Compare April 3, 2025 12:07
@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch 2 times, most recently from 3a8f599 to 703bfd8 Compare April 4, 2025 09:44
@Sahil-Simform Sahil-Simform force-pushed the feature/multishowcase_and_improvement branch from 703bfd8 to ec0d57c Compare April 4, 2025 09:52
@aditya-css aditya-css merged commit 46c0dfc into master Apr 4, 2025
2 checks passed
@aditya-css aditya-css deleted the feature/multishowcase_and_improvement branch April 4, 2025 09:56
thanhle1547 added a commit to thanhle1547/flutter_showcaseview that referenced this pull request Dec 11, 2025
related:
feat: ✨ Multiple showcase at the same time and improvement SimformSolutionsPvtLtd#514
SimformSolutionsPvtLtd#514
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using tutorial over several widgets

3 participants