flutter_app_functions 0.0.3
flutter_app_functions: ^0.0.3 copied to clipboard
Flutter plugin that mirrors the Android App Functions API. Register typed Dart functions that Android agents (Gemini and friends) can discover and invoke on-device.
0.0.3 #
- Added
AppFunctionPlatformNotSupportedException(extendsUnsupportedError). The plugin now fails fast on iOS, macOS, Linux, Windows, and Web before any native code is touched. FlutterAppFunctions.register,registerAll,invoke, andgetPlatformVersionnow throwAppFunctionPlatformNotSupportedExceptionwhendefaultTargetPlatform != android. Local-only operations (unregister,unregisterAll,ensureInitialized, registry getters) remain no-ops on any platform.- The exception's
platformfield carries the offending platform name (e.g."iOS"); the message links todeveloper.android.com/ai/appfunctions. - README: added the new exception to the Errors table and made the "Android only" limitation explicit.
0.0.2 #
- Rewrote the plugin as a faithful wrapper of the Android App Functions API.
- The Kotlin side now exposes a single
@AppFunction executeAppFunctionentry point that dispatches byfunctionIdto a Dart-registered handler. - Replaced the single
registerToolHandlerDart API with a typed, multi-function API:FlutterAppFunctions.instance.register(AppFunctionDefinition(...))/unregister/unregisterAllAppFunctionParameter(string / int64 / double / bool / stringList, optional, enum-constrained)AppFunctionReturnType(voidType / string / int64 / double / boolean / stringList)AppFunctionContext(per-callfunctionId+ validatedparameters)
- Added a typed exception hierarchy mirroring
androidx.appfunctions.AppFunction*Exception1:1:AppFunctionException,AppFunctionInvalidArgumentException,AppFunctionElementNotFoundException,AppFunctionFunctionNotFoundException,AppFunctionNotSupportedException,AppFunctionPermissionRequiredException,AppFunctionDisabledException,AppFunctionAppUnknownException.- The Kotlin bridge now dispatches by
functionIdover a singleparametersJson: String/ resultStringwire channel; typed exceptions are wrapped asPlatformExceptionon the way out and mapped back to theirandroidx.appfunctionssubclass on the way in.
- Added a
FlutterAppFunctionsApplicationbase class that host apps extend to register the bridge with the AppFunctions runtime. - Plugin manifest now contributes the
appfunctions<service>, thexmlns:appfnnamespace, and ares/xml/app_metadata.xmlentry that points at user-overridable strings. - Gradle: added
ksp { arg("appfunctions:aggregateAppFunctions", "true") }so the KSP processor aggregates this module's@AppFunctions with the host app's. - Tests: expanded the Dart
flutter_app_functions_test.dartandflutter_app_functions_method_channel_test.dartsuites, and updated the example integration test. The Kotlin bridge's exception mapping is exercised end-to-end by the integration test (alpha08AppFunction*Exceptionsubclasses cannot be constructed in plain JVM unit tests because their constructors touchandroid.os.Bundle.EMPTY). - Example: registered four sample functions (
createTask,countActiveTasks,searchContacts,markAllTasksDone) demonstrating typed parameters, typed returns, optional parameters, and a typed error. - README: rewrote to mirror
developer.android.com/ai/appfunctionsstructure.
0.0.1 #
- Initial release with Android App Functions support.
- Added a Dart tool-handler bridge through
MethodChannel. - Included an example app and Android unit tests.