device_policy_manager 0.0.1 copy "device_policy_manager: ^0.0.1" to clipboard
device_policy_manager: ^0.0.1 copied to clipboard

PlatformAndroid

Query Android device Administrator (DevicePolicyManager)

example/lib/main.dart

import 'dart:developer';

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

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(
    const MaterialApp(
      home: MyApp(),
    ),
  );
}

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

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

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: SizedBox(
          width: double.infinity,
          child: Center(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                TextButton(
                  onPressed: () async {
                    await DevicePolicyManager.requestPermession(
                        "Your app is requesting the Adminstration permission");
                  },
                  child: const Text("Enable administrative"),
                ),
                const SizedBox(height: 20.0),
                TextButton(
                  onPressed: () async {
                    await DevicePolicyManager.removeActiveAdmin();
                  },
                  child: const Text("Disable administrative"),
                ),
                const SizedBox(height: 20.0),
                TextButton(
                  onPressed: () async {
                    final res = await DevicePolicyManager.isPermissionGranted();
                    log("$res");
                  },
                  child: const Text("Check permission"),
                ),
                const SizedBox(height: 20.0),
                TextButton.icon(
                  onPressed: () async {
                    await DevicePolicyManager.lockNow();
                  },
                  icon: const Icon(Icons.lock),
                  label: const Text("Lock Screen"),
                ),
                const SizedBox(height: 20.0),
                TextButton(
                  onPressed: () async {
                    final res = await DevicePolicyManager.isCameraDisabled();
                    log("Is camera disabled: $res");
                  },
                  child: const Text("Check Camera is disabled ?"),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
20
likes
150
points
339
downloads

Publisher

verified publisheriheb.tech

Weekly Downloads

Query Android device Administrator (DevicePolicyManager)

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on device_policy_manager