google_huawei_availability 1.4.0 copy "google_huawei_availability: ^1.4.0" to clipboard
google_huawei_availability: ^1.4.0 copied to clipboard

PlatformAndroid

A Flutter plugin to detect the availability of the Google Play Services and Huawei HMS Services API on Android devices.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:google_huawei_availability/google_huawei_availability.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  bool _isGoogle = false;
  bool _isHuawei = false;

  @override
  void initState() {
    super.initState();
    checkService();
  }

  /// Sample call to check the services
  Future<void> checkService() async {
    // Google Service
    bool isGoogle =
        await GoogleHuaweiAvailability.isGoogleServiceAvailable ?? false;

    // Huawei Services
    bool isHuawei =
        await GoogleHuaweiAvailability.isHuaweiServiceAvailable ?? false;

    if (!mounted) return;

    setState(() {
      _isGoogle = isGoogle;
      _isHuawei = isHuawei;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Google Huawei Service Availability'),
        ),
        body: Center(
          child: Text(
              'Google Play Service Available: $_isGoogle\nHuawei HMS Service Available: $_isHuawei'),
        ),
      ),
    );
  }
}
18
likes
160
points
1.8k
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to detect the availability of the Google Play Services and Huawei HMS Services API on Android devices.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on google_huawei_availability