flutter_touch_interaction_controller 1.1.0 flutter_touch_interaction_controller: ^1.1.0 copied to clipboard
A Flutter plugin to detect and handle touch events on the screen for Android device.
Flutter Touch Interaction Controller #
- Description: A Flutter plugin to detect and handle touch events on the screen for Android device.
- Technology stack: Flutter plugin.
- Status: CHANGELOG.
Main Features #
- One-touch event recognition and stream provision.
- Requesting accessibilityService permission.
- Verifying accessibilityService permission.
- One-touch execution.
- Touch swife execution.
Screenshot: Sample screenshot of the project,
Installation #
Add dependencies #
Add the following dependency to your pubspec.yaml file:
dependencies:
flutter_touch_interaction_controller: ^1.1.0
Change Android settings #
- Add the following code after the activity section in the android/app/src/main/AndroidManifest.xml file:
<service
android:name="com.rabbitson87.flutter_touch_interaction_controller.AccessibilityServicePlugin"
android:exported="true"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" />
</service>
- Create android/app/src/main/res/xml/accessibility_service_config.xml file and add the following code:
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeAllMask"
android:accessibilityFeedbackType="feedbackSpoken"
android:accessibilityFlags="flagDefault"
android:canPerformGestures="true"
android:canRequestTouchExplorationMode="true"
android:notificationTimeout="100" />
Usage #
Check if the accessibility permission is enabled:
bool isAccessibilityPermissionEnabled = await FlutterTouchInteractionController.isAccessibilityPermissionEnabled;
Request accessibility permission:
await FlutterTouchInteractionController.requestAccessibilityPermission;
Listen to the touch events:
final accessStream = FlutterTouchInteractionController.accessStream.listen((event) {
print(event);
});
Remove the listener when it is no longer needed:
accessStream.cancel();
Execute a touch event:
await FlutterTouchInteractionController.touch(Point(x: 350, y: 400));
Execute a swipe event:
await FlutterTouchInteractionController.swipe(Point(x: 350, y: 1400), Point(x: 350, y: 1000));
Getting help #
If you have questions, concerns, bug reports, etc, please file an issue in this repository's Issue Tracker.
Getting involved #
General instructions on how to contribute should be stated with a link to CONTRIBUTING.