dismiss method

void dismiss()

Ends the request without a result, and the controller of the button reports OneTapLocationDiagnostic.tapWithoutAuthorization.

On a device, a tap ends this way when the user closes the confirmation of the system button on Android without answering it, when the permission request of the fallback button is interrupted before the user answers, and when a tap on iOS does not grant access. On iOS, access that is granted later still produces a result for that tap; to test the app in that case, tap the button again and answer the new request.

Throws a StateError if access was granted or the request was answered.

Implementation

void dismiss() {
  _checkNotAnswered();
  if (_isCancelled) {
    return;
  }
  if (_state == _FakeRequestState.locating) {
    throw StateError(
      'A request that was granted access cannot be dismissed.',
    );
  }
  _state = _FakeRequestState.answered;
  _listener
    ..onDiagnostic(OneTapLocationDiagnostic.tapWithoutAuthorization)
    ..onDone();
}