[Proposal] Add u2_flutter - Flutter driver plugin for uiautomator2
Proposal: u2_flutter - Flutter Driver Plugin for uiautomator2
The Problem
Flutter apps render their entire UI onto a single native FlutterView surface. From the native Android view hierarchy perspective, the canvas is empty - uiautomator2 cannot inspect Flutter widgets like TextField, ElevatedButton, or any widget with a Key.
This means uiautomator2 users cannot automate Flutter apps using the familiar d(resourceId=...) pattern.
Why a Standalone Extension?
Following the u2_webview pattern, u2_flutter is built as a standalone package that works with an existing uiautomator2.Device object. This approach:
- ✅ Requires no changes to the uiautomator2 core
- ✅ Keeps Flutter-specific logic separate and maintainable
- ✅ Follows the proven Flask-extension pattern
- ✅ Can be independently installed and updated
Simple Usage Example
import uiautomator2 as u2
from u2_flutter import Flutter, with_flutter
d = u2.connect()
flutter = Flutter(d)
# Simple object API
flutter.find_by_key("submit_btn").tap()
flutter.find_by_key("username_input").enter_text("testuser")
# Optional lifecycle decorator
@with_flutter
def test():
self.flutter.find_by_key("submit_btn").tap()Current Development Status
✅ Phase 1: Core plugin (bridge, driver, decorators) ✅ Phase 2: API alignment + unit tests (19 tests passing) ✅ Phase 3: Full Kea2 integration (PR submitted) ✅ Documentation: Complete README with examples
Test Results:
- Unit Tests: 19 passing
- Manual Tests: 6/6 passing
- Kea2 Integration Tests: 3/3 passing
Relationship with uiautomator2, u2_flutter, and Kea2
uiautomator2 (Core)
├── Device object
│ │
│ └── u2_flutter (Standalone Plugin)
│ │
│ ├── Flutter(d) - Python API
│ ├── ADB + WebSocket connection
│ └── JSON-RPC to Flutter VM
│
└── Kea2 (Property-Based Testing)
└── Uses u2_flutter for Flutter appsKey Points:
u2_flutterdepends only on the publicuiautomator2.Deviceinterfaceuiautomator2core does not need modificationKea2can useu2_flutterfor property-based fuzzing on Flutter apps
Why This Matters
| Feature | Appium Flutter Driver | u2_flutter |
|---|---|---|
| Communication | HTTP → Node.js → WebSocket | Direct WebSocket |
| Latency | High (4+ hops) | Low (1 hop) |
| Dependencies | Node.js, Appium Server | Python only |
| uiautomator2 Integration | No | Yes |
| Kea2 Integration | No | Yes |
Repository
GitHub: https://github.com/assassinaj602/u2_flutter
Request
I'd like to request:
- Feedback on the API design and approach
- Consideration for eventual listing as an official plugin in the uiautomator2 README
- Community input on additional features or improvements
Future Plans
- PyPI release - Make it pip installable
- More finder types - Add byTooltip, bySemanticsLabel
- iOS support - Extend to Flutter iOS apps
- Official plugin listing - In uiautomator2 README
No changes to uiautomator2 core are required. This is a standalone plugin.
Thank you for considering this proposal!
Source: openatx/uiautomator2