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

An all-in-one Flutter utility package for app maintenance, upgrader dialogs, flashlight, mock location check, wifi signal strength, system volume, mute status, network ping, local IP, biometrics check [...]

example/lib/main.dart

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

void main() {
  runApp(const UpgradeAlert(child: MyApp()));
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

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

class _MyAppState extends State<MyApp> {
  final _appCare = AppCare();
  bool _isConnected = true;
  NetworkType _netType = NetworkType.none;
  AppBaseInfo? _appInfo;
  DeviceInfo? _deviceInfo;
  GeoLocation? _location;
  BatteryInfo? _batteryInfo;
  StorageInfo? _storageInfo;
  AppLaunchInfo? _launchInfo;
  ThermalStatus _thermal = ThermalStatus.normal;
  bool _isLowRam = false;
  bool _isDark = false;
  String _locale = '...';
  bool _isSecurityEnabled = false;
  bool _keepScreenOn = false;
  double _volume = 1.0;
  bool _isMuted = false;
  int _pingMs = -1;
  String _localIp = '...';
  bool _hasBiometrics = false;
  double _fontScale = 1.0;
  bool _isMockLoc = false;
  bool _isAutoTime = true;
  bool _isScreenRecording = false;
  bool _hasWhatsApp = false;
  int _wifiSignal = 0;
  bool _isTorchOn = false;

  @override
  void initState() {
    super.initState();
    _initConnectivityListener();
    _getData();
  }

  void _initConnectivityListener() {
    _appCare.checkConnectivity().then((value) {
      if (mounted) setState(() => _isConnected = value);
    });

    _appCare.onConnectivityChanged.listen((status) {
      if (mounted) setState(() => _isConnected = status);
    });
  }

  Future<void> _getData() async {
    final appInfo = await _appCare.getAppBaseInfo();
    final deviceInfo = await _appCare.getDeviceInfo();
    final battery = await _appCare.getBatteryInfo();
    final storage = await _appCare.getStorageInfo();
    final netType = await _appCare.getNetworkType();
    final locale = await _appCare.getDeviceLocale();
    final launch = await _appCare.getAppLaunchInfo();
    final thermal = await _appCare.getThermalStatus();
    final lowRam = await _appCare.isLowMemory();
    final dark = await _appCare.isDarkMode();
    final volume = await _appCare.getVolume();
    final muted = await _appCare.isMuted();
    final ip = await _appCare.getLocalIpAddress();
    final bio = await _appCare.canAuthenticateBiometrics();
    final fontScale = await _appCare.getFontScale();
    final ping = await _appCare.pingHost();
    final mockLoc = await _appCare.isMockLocation();
    final autoTime = await _appCare.isAutomaticTime();
    final recording = await _appCare.isScreenBeingRecorded();
    final whatsApp = await _appCare.isAppInstalled('com.whatsapp');
    final wifiSignal = await _appCare.getWifiSignalStrength();

    if (mounted) {
      setState(() {
        _appInfo = appInfo;
        _deviceInfo = deviceInfo;
        _batteryInfo = battery;
        _storageInfo = storage;
        _netType = netType;
        _locale = locale;
        _launchInfo = launch;
        _thermal = thermal;
        _isLowRam = lowRam;
        _isDark = dark;
        _volume = volume;
        _isMuted = muted;
        _localIp = ip ?? 'Unavailable';
        _hasBiometrics = bio;
        _fontScale = fontScale;
        _pingMs = ping;
        _isMockLoc = mockLoc;
        _isAutoTime = autoTime;
        _isScreenRecording = recording;
        _hasWhatsApp = whatsApp;
        _wifiSignal = wifiSignal;
      });
    }
  }

  Future<void> _toggleSecurity(bool value) async {
    final success = await _appCare.setScreenSecurity(enable: value);
    if (mounted && success) {
      setState(() => _isSecurityEnabled = value);
    }
  }

  Future<void> _toggleKeepScreenOn(bool value) async {
    final success = await _appCare.setKeepScreenOn(keepOn: value);
    if (mounted && success) {
      setState(() => _keepScreenOn = value);
    }
  }

  Future<void> _getLocation() async {
    final loc = await _appCare.getCurrentLocation();
    if (mounted) {
      setState(() {
        _location = loc;
      });
    }
  }

  Future<void> _toggleTorch() async {
    final success = await _appCare.toggleFlashlight();
    if (mounted && success) {
      setState(() => _isTorchOn = !_isTorchOn);
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('AppCare Flutter Demo')),
        body: SingleChildScrollView(
          padding: const EdgeInsets.all(16),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              const UpgradeCard(),
              const SizedBox(height: 10),

              Container(
                padding: const EdgeInsets.all(12),
                color: _isConnected ? Colors.green[100] : Colors.red[100],
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Icon(
                      _isConnected ? Icons.wifi : Icons.wifi_off,
                      color: _isConnected ? Colors.green : Colors.red,
                    ),
                    const SizedBox(width: 8),
                    Expanded(
                      child: Text(
                        'Internet: ${_isConnected ? "Online" : "Offline"} (${_netType.name.toUpperCase()}) | Ping: ${_pingMs}ms | Wi-Fi Signal: $_wifiSignal/4',
                        style: const TextStyle(fontWeight: FontWeight.bold),
                      ),
                    ),
                  ],
                ),
              ),
              const SizedBox(height: 20),

              _buildInfoCard("App & Launch Info", [
                "Name: ${_appInfo?.appName ?? '...'}",
                "Package: ${_appInfo?.packageName ?? '...'}",
                "Version: ${_appInfo?.version ?? '...'} (${_appInfo?.buildNumber ?? '...'})",
                "Locale: $_locale",
                "Dark Mode: $_isDark",
                "Font Scale: ${_fontScale.toStringAsFixed(2)}x",
                "Session Uptime: ${_launchInfo?.sessionUptimeSeconds ?? 0}s",
              ]),

              const SizedBox(height: 10),

              _buildInfoCard("Security & Anti-Cheat Status", [
                "Fake GPS / Mock Location: ${_isMockLoc ? 'DETECTED!' : 'Clean'}",
                "Network Auto-Time Sync: ${_isAutoTime ? 'Synced' : 'Manual Time'}",
                "Active Screen Recording: ${_isScreenRecording ? 'Recording Active' : 'None'}",
                "WhatsApp Installed: $_hasWhatsApp",
              ]),

              const SizedBox(height: 10),

              _buildInfoCard("Hardware & Audio Diagnostics", [
                "Device: ${_deviceInfo?.manufacturer} ${_deviceInfo?.model}",
                "OS: ${_deviceInfo?.osName} ${_deviceInfo?.osVersion}",
                "Battery: ${_batteryInfo?.batteryLevel ?? -1}% (${_batteryInfo?.isCharging == true ? 'Charging' : 'Discharging'})",
                "Thermal Status: ${_thermal.name.toUpperCase()}",
                "Low RAM Alert: $_isLowRam",
                "Media Volume: ${(_volume * 100).toInt()}% (Muted: $_isMuted)",
                "Local IP: $_localIp",
                "Biometrics Hardware Enrolled: $_hasBiometrics",
              ]),

              const SizedBox(height: 10),

              _buildInfoCard("Storage Info", [
                "Free Storage: ${_storageInfo != null ? '${_storageInfo!.freeGB.toStringAsFixed(2)} GB' : '...'}",
                "Total Storage: ${_storageInfo != null ? '${_storageInfo!.totalGB.toStringAsFixed(2)} GB' : '...'}",
              ]),

              const SizedBox(height: 10),

              _buildInfoCard(
                "Location",
                [
                  _location != null ? "Lat: ${_location!.latitude}" : "Lat: -",
                  _location != null ? "Lng: ${_location!.longitude}" : "Lng: -",
                ],
                trailing: IconButton(
                  icon: const Icon(Icons.my_location),
                  onPressed: _getLocation,
                ),
              ),

              const SizedBox(height: 20),
              Card(
                child: Column(
                  children: [
                    SwitchListTile(
                      title: const Text('Screen Security (Block Screenshots)'),
                      subtitle: Text(
                        _isSecurityEnabled ? 'Protected' : 'Disabled',
                      ),
                      value: _isSecurityEnabled,
                      onChanged: _toggleSecurity,
                    ),
                    SwitchListTile(
                      title: const Text('Keep Screen Awake (WakeLock)'),
                      subtitle: Text(_keepScreenOn ? 'Awake' : 'Default'),
                      value: _keepScreenOn,
                      onChanged: _toggleKeepScreenOn,
                    ),
                  ],
                ),
              ),
              const SizedBox(height: 20),
              const Divider(),
              Wrap(
                spacing: 8,
                runSpacing: 8,
                children: [
                  ElevatedButton.icon(
                    onPressed: _toggleTorch,
                    icon: Icon(_isTorchOn ? Icons.flash_off : Icons.flash_on),
                    label: Text(_isTorchOn ? 'Torch Off' : 'Torch On'),
                  ),
                  ElevatedButton.icon(
                    onPressed: () => _appCare.vibrate(type: HapticType.medium),
                    icon: const Icon(Icons.vibration),
                    label: const Text('Vibrate'),
                  ),
                  ElevatedButton.icon(
                    onPressed: () => _appCare.playSystemBeep(),
                    icon: const Icon(Icons.volume_up),
                    label: const Text('System Beep'),
                  ),
                  ElevatedButton.icon(
                    onPressed: () async {
                      final messenger = ScaffoldMessenger.of(context);
                      await _appCare.setAppBadgeCount(5);
                      messenger.showSnackBar(
                        const SnackBar(
                          content: Text('App Icon Badge Set to 5'),
                        ),
                      );
                    },
                    icon: const Icon(Icons.mark_email_unread),
                    label: const Text('Set Badge (5)'),
                  ),
                  ElevatedButton.icon(
                    onPressed: () async {
                      final messenger = ScaffoldMessenger.of(context);
                      await _appCare.copyToClipboard('Hello from AppCare!');
                      messenger.showSnackBar(
                        const SnackBar(content: Text('Copied to Clipboard!')),
                      );
                    },
                    icon: const Icon(Icons.copy),
                    label: const Text('Copy Clipboard'),
                  ),
                  ElevatedButton.icon(
                    onPressed: () => _appCare.openUrl('https://rahulreza.com'),
                    icon: const Icon(Icons.language),
                    label: const Text('Open Web URL'),
                  ),
                  ElevatedButton.icon(
                    onPressed: () => _appCare.openEmail(
                      'contact@rahulreza.com',
                      subject: 'AppCare Demo',
                    ),
                    icon: const Icon(Icons.email),
                    label: const Text('Open Email'),
                  ),
                  ElevatedButton.icon(
                    onPressed: () => _appCare.openDialer('+8801700000000'),
                    icon: const Icon(Icons.phone),
                    label: const Text('Open Dialer'),
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }

  Widget _buildInfoCard(String title, List<String> lines, {Widget? trailing}) {
    return Card(
      elevation: 2,
      child: Padding(
        padding: const EdgeInsets.all(12),
        child: Column(
          children: [
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: [
                Text(
                  title,
                  style: const TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.bold,
                  ),
                ),
                if (trailing != null) trailing,
              ],
            ),
            const Divider(),
            ...lines.map(
              (l) => Padding(
                padding: const EdgeInsets.symmetric(vertical: 2),
                child: Align(alignment: Alignment.centerLeft, child: Text(l)),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
7
likes
0
points
155
downloads

Publisher

verified publisherrahulreza.com

Weekly Downloads

An all-in-one Flutter utility package for app maintenance, upgrader dialogs, flashlight, mock location check, wifi signal strength, system volume, mute status, network ping, local IP, biometrics check, app badge, font scale, system beep, wake lock, haptics, clipboard, orientation, thermal status, battery, network type, screen security, storage info, update checking, and in-app reviews using raw code only.

Homepage

Topics

#app-maintenance #upgrader #connectivity #haptics #battery

License

unknown (license)

Dependencies

flutter

More

Packages that depend on appcare_flutter

Packages that implement appcare_flutter