checkGmsAvailability method
Just need to call this once when app initialize. Then use GmsTools().isGmsAvailable getter instead.
Implementation
Future<bool?> checkGmsAvailability({bool enableLog = false}) async {
WidgetsFlutterBinding.ensureInitialized();
_isGmsAvailable = false;
try {
final status = await _channel.invokeMethod(_isGmsAvailableMethod);
if (enableLog) {
debugPrint('[GMS Availability]: ${status.toString()}');
}
_isGmsAvailable = status;
} on PlatformException {
if (enableLog) {
debugPrint('[GMS Availability]: Failed to get isGmsAvailable.');
}
} on MissingPluginException {
/// Just need to check for Android.
/// Default true for other OS.
_isGmsAvailable = true;
}
return _isGmsAvailable;
}