close method

void close()

Close the datepicker popup.

Implementation

void close() {
  if (!_popupVisible) return;

  _popupVisible = false;
  _onPopupVisible.add(false);
  popup?.close();

  _domService.nextFrame!.then((_) {
    // Double-check that the popup is still closing.
    if (_popupVisible) return;

    _ngZone.run(() {
      // Cancel changes if apply isn't in progress.
      if (!_isApplying) {
        model.restore(_lastState);
        selection.value = _lastState!.value;
        _showApplyBar(!_isPreset(_lastState!.value));
      }
      _isApplying = false;
    });
  });
}