CurrentAppDetector class
A class to interact with native platform functionality for detecting the current foreground application and interacting with system features.
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
checkAccessibilityPermission(
) → Future< bool> -
Checks if the Accessibility Service for this app is enabled.
Returns
trueif the service is enabled,falseotherwise. -
checkUsagePermission(
) → Future< bool> -
Checks if Usage Stats permission has been granted.
Returns
trueif permission is granted,falseotherwise. -
getAccessibilityPermission(
) → Future< String> - Requests Accessibility permission from the user. This will open the system's accessibility settings screen. Returns "granted" if the service is already enabled, or "need_permission" if the settings screen was opened.
-
getCurrentApp(
) → Future< String> - Gets the package name of the current foreground app. Requires Usage Stats permission on Android. Returns the package name as a String.
-
getScreenText(
) → Future< String> - Retrieves all text currently visible on the screen. Requires the Accessibility Service to be enabled. Returns the screen text as a single String.
-
getUsagePermission(
) → Future< String> - Requests Usage Stats permission from the user. This will open the system settings screen for the user to grant access. Returns "granted" if permission is already enabled, or "need_permission" if the settings screen was opened.
-
goHome(
) → Future< bool> -
Navigates to the device's home screen.
Returns
trueon success, otherwise throws an exception. -
launchApp(
String packageName) → Future< bool> -
Launches an app by its package name (if it's installed).
packageNameis the package identifier of the app to launch. Returnstrueif launch was successful, otherwise throws an exception.