otpCountdownUi method

Widget otpCountdownUi({
  1. required Widget builder(
    1. int seconds
    ),
})

A simplified reactive StreamBuilder UI helper for the OTP resend countdown.

The builder receives only the remaining seconds as an int.

Implementation

Widget otpCountdownUi({required Widget Function(int seconds) builder}) {
  return StreamBuilder<int>(
    stream: otpManager.resendCountdown.stream,
    initialData: otpManager.resendCountdown.value,
    builder: (context, snapshot) {
      if (snapshot.hasError) {
        return const SizedBox.shrink();
      }
      return builder(snapshot.data ?? 0);
    },
  );
}