Skip to content

Commit

Permalink
✨ feature/previous_next_function_added
Browse files Browse the repository at this point in the history
  • Loading branch information
shwetachauhan-simform committed Mar 4, 2022
1 parent 375cf71 commit 020ab28
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- Fixed [#121](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/121) - SlideTransition widget in tooltip_widget.dart is constantly rebuildung even after the showcasing is supposed to have stopped
- Fixed [#152](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/152) - Calculation of tooltip position
- Fixed [#182](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/182) - Not providing blurValue causes Exception: Please provide ShowCaseView context
- Fixed [#162](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/162) - Add feature to move back
- Fixed [#181](https://github.com/SimformSolutionsPvtLtd/flutter_showcaseview/issues/181) - Add feature to go to previous item

## [1.1.4] - November 26, 2021

Expand Down
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ ShowCaseWidget(
),
```

8. Go to next `ShowCase`
```dart
someEvent(){
ShowCaseWidget.of(context).next();
}
```

9. Go to previous `ShowCase`
```dart
someEvent(){
ShowCaseWidget.of(context).previous();
}
```

If you want to start the `ShowCaseView` as soon as your UI built up then use below code.

```dart
Expand Down
33 changes: 33 additions & 0 deletions lib/src/showcase_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,39 @@ class ShowCaseWidgetState extends State<ShowCaseWidget> {
}
}

void next() {
if (ids != null && mounted) {
setState(() {
_onComplete();
activeWidgetId = activeWidgetId! + 1;
_onStart();

if (activeWidgetId! >= ids!.length) {
_cleanupAfterSteps();
if (widget.onFinish != null) {
widget.onFinish!();
}
}
});
}
}

void previous() {
if (ids != null && ((activeWidgetId ?? 0) - 1) >= 0 && mounted) {
setState(() {
_onComplete();
activeWidgetId = activeWidgetId! - 1;
_onStart();
if (activeWidgetId! >= ids!.length) {
_cleanupAfterSteps();
if (widget.onFinish != null) {
widget.onFinish!();
}
}
});
}
}

void dismiss() {
if (mounted) {
setState(_cleanupAfterSteps);
Expand Down

0 comments on commit 020ab28

Please sign in to comment.