toggleVisible method Null safety

void toggleVisible(
  1. {int? autoHideButtonTime}
)

Function to auto hide the button class.

Implementation

void toggleVisible({int? autoHideButtonTime}) async {
  if (!(value.visible)) {
    value = value.copyWith(visible: !(value.visible));
    timer = Timer(Duration(seconds: autoHideButtonTime ?? 5), () {
      if (!(value.visible)) return;
      value = value.copyWith(visible: !(value.visible));
    });
  } else {
    timer?.cancel();
    value = value.copyWith(visible: !(value.visible));
  }
}