showInfoDialog static method

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

Implementation

static void showInfoDialog(BuildContext context,
    {required GlobalKey key,
    required String shape,
    required String title,
    required String body,
    Function()? onOkPressed}) {
  var isDarkTheme = Theme.of(context).brightness == Brightness.dark;
  List<TargetFocus> targets = [];
  targets.add(
    TargetFocus(
      shape: shape.toString().toLowerCase() == "rect"
          ? ShapeLightFocus.RRect
          : ShapeLightFocus.Circle,
      identify: "keyDialog",
      keyTarget: key,
      alignSkip: Alignment.topRight,
      enableOverlayTab: true,
      contents: [
        TargetContent(
          align: ContentAlign.bottom,
          builder: (context, controller) {
            return AlertDialog(
              backgroundColor: isDarkTheme ? Colors.black : Colors.white,
              title: Text(
                title,
              ),
              // backgroundColor: AppTheme.backgroundColor,
              content: SingleChildScrollView(
                child: ListBody(
                  children: <Widget>[
                    Text(
                      body,
                    ),
                  ],
                ),
              ),
              actions: <Widget>[
                // TextButton(
                //   onPressed: () => Navigator.pop(context),
                //   child: const Text(
                //     'Cancel',
                //   ),
                // ),
                TextButton(
                  onPressed: onOkPressed == null
                      ? () {
                          tutorialCoachMark.finish();
                        }
                      : () {
                          tutorialCoachMark.finish();
                          onOkPressed();
                        },
                  child: const Text(
                    'OK',
                  ),
                ),
              ],
            );
          },
        ),
      ],
    ),
  );

  PagePilot.initTutorialCoachMark(targets);
  tutorialCoachMark.show(context: context);
}