lukepighetti / flutter_hotspot

Simple tours, coachmarks, and tutorials. Just tag your Widgets!
https://pub.dev/packages/hotspot
MIT License
139 stars 14 forks source link

Call back or on done pressed handler? #11

Open rlee1990 opened 1 month ago

rlee1990 commented 1 month ago

Is there a way to know when the done button is pressed or when the tour is done?

godilite commented 3 weeks ago

@lukepighetti this is quite important for us also. Is there any possibilities?

godilite commented 3 weeks ago

@rlee1990 I think a way that this could be done is to provide your own actionBuilder widget, and here you will receive a CalloutActionController controller. The controller has some properties

/// The current target's index.
  final int index;

  /// The total number of targets.
  final int pages;

  /// Convenience getter for if we're currently on the last page.
  bool get isLastPage => index + 1 == pages;

  /// Convenience getter for if we're currently on the first page.
  bool get isFirstPage => index == 0;

You can then check controller.isLastPage in your next button onPressed callback and handle done

Pretty much copy this default design https://github.com/lukepighetti/flutter_hotspot/blob/main/lib/src/hotspot_action_builder.dart and handle the last page check just above controller.next()