elevatedButtonFunction function

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

Implementation

Widget elevatedButtonFunction(
  BuildContext context,
  Widget widget,
  VoidCallback? callback,
  int? enablePop,
  int widgetType,
) {
  return ElevatedButton(
    style: ElevatedButton.styleFrom(
      elevation: 0.0,
      backgroundColor: Colors.transparent,
      foregroundColor: Colors.black,
      shadowColor: Colors.transparent,
      disabledBackgroundColor: Colors.transparent,
    ),
    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,
  );
}