okButton method Null safety

Widget okButton(
  1. Future<void> okPressed(
      )?
    )

    A dialogue 'OK' button which executes okPressed when pressed.

    Implementation

    static Widget okButton(Future<void> Function()? okPressed) {
      return TextButton(
        onPressed: okPressed == null
            ? null
            : () async {
                await okPressed();
              },
        child: const Text('OK'),
        style: ButtonStyle(
          foregroundColor: MaterialStateProperty.all(Colors.black),
        ),
      );
    }