showTour static method

Future<void> showTour(
  1. BuildContext context,
  2. Config config, {
  3. required DataModel data,
  4. ScrollController? scrollController,
})

Implementation

static Future<void> showTour(
  BuildContext context,
  Config config, {
  required DataModel data,
  ScrollController? scrollController,
}) async {
  List<Widget> widgets = [];
  List<GlobalKey> keys = [];
  List<StepModel> tours = data.steps;
  for (int i = 0; i < tours.length; i++) {
    String body = tours[i].content.toString();
    String textColor = tours[i].textColor.toString();
    String? contentHeight = tours[i].height;
    final key = config.keys[tours[i].selector.toString()];
    keys.add(key);
    if (scrollController != null) {
      await scrollToTarget(key, scrollController);
    }

    WebViewController tourWebViewController = WebviewUtil.init(isTour: true);

    widgets.add(
      SafeArea(
        child: SingleChildScrollView(
          child: Container(
            margin: EdgeInsets.zero,
            padding: EdgeInsets.zero,
            child: WebviewUtil.getWebViewWidget(
              body,
              textColor,
              contentHeight,
              tourWebViewController: tourWebViewController,
            ),
          ),
        ),
      ),
    );

    WebviewUtil.load(
      null,
      body,
      tourWebViewController: tourWebViewController,
    );
  }
  TourUtil.show(
    context,
    widgets: widgets,
    keys: keys,
    data: data,
    targetIdentifier: "keyTour",
  );
}