showTutorial static method
Implementation
static showTutorial(BuildContext context, List<TutorialItem> children) async {
int count = 0;
var size = MediaQuery.of(context).size;
OverlayState? overlayState = Overlay.of(context);
List<OverlayEntry> entrys = [];
children.forEach((element) async {
var offset = _capturePositionWidget(element.globalKey);
var sizeWidget = _getSizeWidget(element.globalKey);
entrys.add(
OverlayEntry(
builder: (context) {
return GestureDetector(
onTap: element.touchScreen == true
? () {
entrys[count].remove();
count++;
if (count != entrys.length) {
overlayState?.insert(entrys[count]);
}
}
: () {},
child: Scaffold(
backgroundColor: Colors.transparent,
body: Stack(
children: [
CustomPaint(
size: size,
painter: HolePainter(
shapeFocus: element.shapeFocus,
dx: offset.dx + (sizeWidget.width / 2),
dy: offset.dy + (sizeWidget.height / 2),
width: sizeWidget.width,
height: sizeWidget.height),
),
Positioned(
top: element.top,
bottom: element.bottom,
left: element.left,
right: element.right,
child: Container(
width: size.width * 0.8,
child: Column(
crossAxisAlignment: element.crossAxisAlignment,
mainAxisAlignment: element.mainAxisAlignment,
children: [
...element.children!,
GestureDetector(
child: element.widgetNext ??
Text(
"NEXT",
style: TextStyle(color: Colors.white),
),
onTap: () {
entrys[count].remove();
count++;
if (count != entrys.length) {
overlayState?.insert(entrys[count]);
}
},
),
],
),
),
)
],
),
),
);
},
),
);
});
overlayState?.insert(entrys[0]);
}