disable function

Widget disable(
  1. {Key? key,
  2. bool disabled = true,
  3. Widget? child}
)

A widget that disables user interaction with its child widget.

This widget wraps the provided child widget and makes it unresponsive to user input when the disabled flag is set to true.

Implementation

Widget disable({
  Key? key,
  bool disabled = true,
  Widget? child,
}) {
  return IgnorePointer(
    ignoring: disabled,
    child: disabled
      ? Container(
          foregroundDecoration: const BoxDecoration(
            color: Colors.black,
            backgroundBlendMode: BlendMode.saturation,
          ),
          child: Opacity(
            opacity: 0.7,
            child: child,
          ),
        )
      : child,
  );
}