showTour static method
Future<void>
showTour(
- BuildContext context,
- Config config, {
- required DataModel data,
- ScrollController? scrollController,
- bool showNextAndPreviousButtons = false,
- required Map gkeys,
Implementation
static Future<void> showTour(
BuildContext context,
Config config, {
required DataModel data,
ScrollController? scrollController,
bool showNextAndPreviousButtons = false,
required Map<dynamic, dynamic> gkeys,
}) async {
List<Widget> widgets = [];
List<GlobalKey> keys = [];
List<StepModel> tours = data.steps;
for (int i = 0; i < tours.length; i++) {
// final tooltip = SuperTooltipController();
WebViewController tourWebViewController = WebviewUtil.init(isTour: true);
String body = tours[i].content.toString();
String textColor = tours[i].textColor.toString();
String? contentHeight = tours[i].height;
String? contentwidth = tours[i].width;
final key = gkeys[tours[i].selector.toString()];
keys.add(key);
if (scrollController != null) {
await scrollToTarget(key, scrollController);
}
widgets.add(
SingleChildScrollView(
child: Container(
margin: EdgeInsets.zero,
padding: EdgeInsets.zero,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 20),
WebviewUtil.getWebViewWidget(
targetKey: key,
body,
textColor,
contentHeight: contentHeight,
contentwidth: contentwidth,
tourWebViewController: tourWebViewController,
step: tours[i],
),
if (showNextAndPreviousButtons) ...{
const SizedBox(height: 20),
previousAndNextButtons(
i,
tours.length - 1,
),
}
],
),
),
),
);
WebviewUtil.load(
null,
body,
tourWebViewController: tourWebViewController,
);
}
//TODO: fix this temporary hack
Future.delayed(Duration(milliseconds: 500), () async {
bool? isDisposed = await Pref.readBool('disposed');
if (isDisposed != true) {
TourUtil.show(
context,
widgets: widgets,
keys: keys,
data: data,
targetIdentifier: "keyTour",
);
}
});
}