cupertinoButtonFunction function

Widget cupertinoButtonFunction(
  1. BuildContext context,
  2. Widget widget,
  3. VoidCallback? callback,
  4. int? enablePop,
  5. int widgetType,
)

Implementation

Widget cupertinoButtonFunction(
  BuildContext context,
  Widget widget,
  VoidCallback? callback,
  int? enablePop,
  int widgetType,
) {
  return CupertinoButton(
    onPressed: (() {
      //0:cancel widget,1:ensure widget
      if (widgetType == 1) {
        if (enablePop == 1) {
          return () async {
            Navigator.of(context).pop();
            if (callback != null) {
              callback();
            }
          };
        } else {
          if (callback != null) {
            return () async {
              callback();
            };
          }
        }
      } else {
        return () async {
          Navigator.of(context).pop();
          if (callback != null) {
            callback();
          }
        };
      }
    })(),
    child: widget,
  );
}