checkGooglePlayServicesAvailability method

Future<GooglePlayServicesAvailability> checkGooglePlayServicesAvailability([
  1. bool showDialogIfNecessary = false
])

Returns the connection status of Google Play Services.

Optionally, you can also show an error dialog if the connection status is not SUCCESS.

Implementation

Future<GooglePlayServicesAvailability> checkGooglePlayServicesAvailability(
    [bool showDialogIfNecessary = false]) async {
  if (GoogleApiAvailabilityPlatform.instance == null) {
    throw UnsupportedError('This platform is not supported.');
  }

  final availability = await GoogleApiAvailabilityPlatform.instance!
      .checkGooglePlayServicesAvailability(showDialogIfNecessary);

  return GooglePlayServicesAvailability.values[availability.value];
}