a11y_service 0.0.14 copy "a11y_service: ^0.0.14" to clipboard
a11y_service: ^0.0.14 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'),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
0
likes
130
pub points
26%
popularity

Publisher

verified publisherliasica.com

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