showDialogBox function

dynamic showDialogBox (
  1. {@required BuildContext context,
  2. Color bgColor,
  3. @required Widget content,
  4. Curve curve: Curves.bounceOut,
  5. VoidCallback onOktap,
  6. VoidCallback onNotOk}
)

Implementation

showDialogBox(
    {@required BuildContext context,
    // @required String heading,
    // @required String subheading,
    Color bgColor,
    @required Widget content,
    Curve curve = Curves.bounceOut,
    VoidCallback onOktap,
    VoidCallback onNotOk}) {
  showDialog(
      context: context,
      builder: (context) {
        bgColor ??= Color.fromARGB(255, 34, 51, 85);

        List<Widget> widgets = [];
        if (onNotOk != null) {
          widgets.add(
            SafeArea(
              child: IconButton(
                icon: Icon(
                  Icons.close,
                  color: Colors.red[400],
                  size: 36,
                ),
                onPressed: () {
                  onNotOk();
                  Navigator.pop(context);
                  Navigator.of(context).pop();
                },
              ),
            ),
          );
        }

        if (onOktap != null) {
          widgets.add(
            SafeArea(
              child: IconButton(
                icon: Icon(
                  Icons.check,
                  color: Colors.green,
                  size: 36,
                ),
                onPressed: () {
                  onOktap();
                  Navigator.pop(context);
                },
              ),
            ),
          );
        }

        final Widget child = SingleChildScrollView(
          child: Center(
            child: Padding(
              padding: EdgeInsets.all(MediaQuery.of(context).size.width * 0.1),
              child: Material(
                color: bgColor,
                borderRadius: BorderRadius.circular(20),
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    content,
                    // sb(25),
                    // Text(
                    //   heading,
                    //   textAlign: TextAlign.center,
                    //   style: Theme.of(context).textTheme.body2
                    //       .copyWith(color: Colors.red[500]),
                    // ),
                    // sb(25),
                    // Padding(
                    //   padding: EdgeInsets.symmetric(horizontal: sz(20)),
                    //   child: Text(
                    //     subheading,
                    //     textAlign: TextAlign.center,
                    //     style: Theme.of(context).textTheme.body2
                    //         .copyWith(color: Colors.white),
                    //   ),
                    // ),
                    // sb(30),
                    Row(
                        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                        children: widgets
                        // children: <Widget>[
                        //   // onOktap !=null ? :,
                        //   SafeArea(
                        //     child: IconButton(
                        //       icon: Icon(
                        //         Icons.close,
                        //         color: Colors.red[400],
                        //         size: sz(36),
                        //       ),
                        //       onPressed: onNotOk,
                        //     ),
                        //   ),
                        //   SafeArea(
                        //     child: IconButton(
                        //       icon: Icon(
                        //         Icons.check,
                        //         color: Colors.white70,
                        //         size: sz(36),
                        //       ),
                        //       onPressed: onOktap,
                        //     ),
                        //   )
                        // ],
                        ),

                    SizedBox(
                      height: 10,
                    ),
                  ],
                ),
              ),
            ),
          ),
        );

        return CurveDelayedAnimation(0,
            curve: curve,
            extent: 100,
            vertical: true,
            horizontal: false,
            child: child);
      });
}