https://github.com/sofluffyos/gms_check
This tiny plugin simply checks if Google Services is available on the Android device.
https://github.com/sofluffyos/gms_check
Last synced: 7 months ago
JSON representation
This tiny plugin simply checks if Google Services is available on the Android device.
- Host: GitHub
- URL: https://github.com/sofluffyos/gms_check
- Owner: SoFluffyOS
- License: apache-2.0
- Created: 2021-09-27T11:32:47.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-28T03:25:25.000Z (over 1 year ago)
- Last Synced: 2025-03-24T17:21:23.975Z (over 1 year ago)
- Language: Dart
- Homepage: https://pub.dev/packages/gms_check
- Size: 1.46 MB
- Stars: 3
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# gms_check
**This tiny plugin simply checks if Google Services is available on the Android device.**
For other platform, it always return `true` as default.
> This will help you to **avoid initializing unnecessary services** that [require **Google Services**](https://firebase.google.com/docs/android/android-play-services) to run on the device, such as: Firebase App Check, Firebase Cloud Messaging,...
## Usage
1. Call `await GmsCheck().checkGmsAvailability()` before `runApp()` in `main()`.
```dart
Future main() async {
/// Need to call GmsCheck().checkGmsAvailability()
/// only once before runApp function.
await GmsCheck().checkGmsAvailability();
runApp(const MyApp());
}
```
2. Use `GmsCheck().isGmsAvailable` any where in the app.
```dart
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Text('GMS available: ${GmsCheck().isGmsAvailable}'),
),
),
);
}
```
You can use `GmsCheck().isGmsAvailable` to conditionally initialize Firebase services.
```dart
if (GmsCheck().isGmsAvailable) {
_initFirebaseAppCheck();
_initFirebaseCloudMessaging();
}
_initFirebaseRemoteConfig();
```