showTour static method
Implementation
static void showTour(
BuildContext context,
Config config, {
required List<dynamic> tours,
// required Widget widget,
}) {
var isDarkTheme = Theme.of(context).brightness == Brightness.dark;
List<TargetFocus> targets = [];
for (int i = 0; i < tours.length; i++) {
String body = tours[i]["body"].toString();
WebViewController webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
NavigationDelegate(
onProgress: (int progress) {
// Update loading bar.
},
onPageStarted: (String url) {},
onPageFinished: (String url) {},
onHttpError: (HttpResponseError error) {},
onWebResourceError: (WebResourceError error) {},
onNavigationRequest: (NavigationRequest request) {
if (request.url.startsWith('https://www.youtube.com/')) {
return NavigationDecision.prevent;
}
return NavigationDecision.navigate;
},
),
);
targets.add(
TargetFocus(
identify: "",
shape: tours[i]["shape"].toString().toLowerCase() == "rect"
? ShapeLightFocus.RRect
: ShapeLightFocus.Circle,
keyTarget: config.keys[tours[i]["element"].toString()],
alignSkip: Alignment.topRight,
enableOverlayTab: true,
contents: [
TargetContent(
align: ContentAlign.bottom,
builder: (context, TCMcontroller) {
return Column(
children: [
Container(
decoration: BoxDecoration(
color: isDarkTheme ? Colors.black : Colors.white,
borderRadius: BorderRadius.circular(borderRadius),
),
padding: EdgeInsets.all(borderRadius),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
tours[i]["title"].toString(),
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
color: isDarkTheme ? Colors.white : Colors.black,
),
),
// Text(tours[i]["description"].toString()),
body.startsWith("http")
? Container(
height: 200,
width: 200,
child: WebViewWidget(
controller: webViewController),
)
: Text(tours[i]["body"].toString()),
],
),
),
SizedBox(height: 20),
previousAndNextButtons(i, tours.length - 1),
],
);
},
),
],
),
);
if (body.startsWith("http")) {
webViewController.loadRequest(Uri.parse(body));
}
}
PagePilot.initTutorialCoachMark(targets);
tutorialCoachMark.show(context: context);
}