showTutorial static method

dynamic showTutorial(
  1. BuildContext context,
  2. List<TutorialItem> children
)

The method that shows the tutorial

Implementation

static showTutorial(BuildContext context, List<TutorialItem> children) async {
  var size = MediaQuery.of(context).size;
  OverlayState overlayState = Overlay.of(context);

  count = 0;

  children.forEach((element) async {
    final offset = _capturePositionWidget(element.globalKey);
    final sizeWidget = _getSizeWidget(element.globalKey);
    entries.add(
      OverlayEntry(
        builder: (context) {
          return GestureDetector(
            onTap: () {
              entries[count].remove();
              count++;
              if (count < entries.length) {
                overlayState.insert(entries[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,
                      color: element.color,
                      borderRadius: element.borderRadius,
                      radius: element.radius,
                    ),
                  ),
                  element.child,
                ],
              ),
            ),
          );
        },
      ),
    );
  });

  overlayState.insert(entries[0]);
}