showTooltip static method

void showTooltip(
  1. BuildContext context, {
  2. required GlobalKey<State<StatefulWidget>> key,
  3. required String shape,
  4. String? title,
  5. int? scale,
  6. required String body,
})

Implementation

static void showTooltip(
  BuildContext context, {
  required GlobalKey key,
  required String shape,
  String? title,
  int? scale,
  required String body,
}) {
  var isDarkTheme = Theme.of(context).brightness == Brightness.dark;
  List<TargetFocus> targets = [];
  targets.add(
    TargetFocus(
      shape: shape.toString().toLowerCase() == "rect"
          ? ShapeLightFocus.RRect
          : ShapeLightFocus.Circle,
      identify: "keyTooltip",
      keyTarget: key,
      alignSkip: Alignment.topRight,
      enableOverlayTab: true,
      contents: [
        TargetContent(
          align: ContentAlign.bottom,
          builder: (context, coachMarkController) {
            return Container(
              decoration: BoxDecoration(
                color: isDarkTheme ? Colors.black : Colors.white,
                borderRadius: BorderRadius.circular(borderRadius),
              ),
              padding: EdgeInsets.all(padding),
              child: Column(
                children: [
                  title != null
                      ? Text(
                          title,
                          style: TextStyle(
                            fontSize: 18,
                            fontWeight: FontWeight.bold,
                          ),
                        )
                      : SizedBox(),
                  SizedBox(height: 10),
                  body.toString().startsWith("<")
                      ? SizedBox(
                          height: 200,
                          width: MediaQuery.of(context).size.width * 0.8,
                          child: WebViewWidget(controller: controller!),
                        )
                      : Text(
                          body,
                          overflow: TextOverflow.clip,
                        ),
                ],
              ),
            );
          },
        ),
      ],
    ),
  );

  PagePilot.initTutorialCoachMark(targets);
  tutorialCoachMark.show(context: context);
  if (body.toString().startsWith("<")) {
    controller!.loadHtmlString(body.toString());
    adjustWebviewZoom(scale: scale ?? 4);
  }
}