a11y_service 0.0.15 copy "a11y_service: ^0.0.15" to clipboard
a11y_service: ^0.0.15 copied to clipboard

PlatformAndroid

A Flutter plugin for Android Accessibility Service.

example/lib/main.dart

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

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

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

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

class _MyAppState extends State<MyApp> {
  final _plugin = A11yService();

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

    _plugin.onAccessibilityEvent.listen((event) {
      // print('$event');
    });

    _plugin.onPermissionChanged.listen((isGranted) {
      print('isGranted: $isGranted');
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Flutter A11y Service Example'),
        ),
        body: SafeArea(
          child: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              mainAxisSize: MainAxisSize.min,
              children: [
                ElevatedButton(
                  onPressed: () async {
                    final isGranted = await _plugin.requestPermission();
                    print('isGranted: $isGranted');
                  },
                  child: const Text('Request Permission'),
                ),
                ElevatedButton(
                  onPressed: () async {
                    final forceStopApp = await _plugin.forceStopApp(
                      'com.android.chrome',
                      determine: '确定',
                      alertDialogName: 'androidx.appcompat.app.AlertDialog',
                      appDetailsName: 'com.android.settings.applications.InstalledAppDetailsTop',
                    );
                    print('forceStopApp: $forceStopApp');
                  },
                  child: const Text('Force stop app'),
                ),
                ElevatedButton(
                  onPressed: () async {
                    final result = await _plugin.analyze();
                    print('analyze: $result');
                  },
                  child: const Text('Analyze'),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
1
likes
130
points
28
downloads

Publisher

verified publisherliasica.com

Weekly Downloads

A Flutter plugin for Android Accessibility Service.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on a11y_service