BLOG
BlogGuides

Test a Flutter app on iPhone and Android, canvas included

Flutter draws its own widgets, which trips up tools that read the native view tree. How Testsy tests Flutter apps, the iOS build to upload, and drawn content.

Flutter draws its own screen#

Flutter does not use the platform's native buttons and lists. It draws every widget itself and exposes a separate accessibility (semantics) tree describing them. Tools that find elements in the native view tree see little of a Flutter app unless that semantics tree is complete, and content painted on a canvas (charts, drawings, games) is not in any tree at all.

How Testsy handles it#

The tester reads the Flutter semantics tree on both platforms, and reads the screen itself where the tree runs out. We test the engine against a Flutter app of our own with five tabs chosen to be awkward: default widgets whose labels merge into one node, unlabelled switches, a chart drawn with CustomPaint, a drawing canvas whose counter is painted rather than written, and a game excluded from the semantics tree entirely. Content that only exists as pixels is read from the screen, and small targets are zoomed in on before a tap.

What that means for you: a test like "check the chart's last bar reads 42" can pass on a chart with no semantics at all, and the evidence shows the crop of the screen it read.

The builds#

  • Android: flutter build apk --target-platform android-arm64,android-x64. Both architectures are needed, because our Android emulators come in two kinds. The APK is at build/app/outputs/flutter-apk/app-release.apk. Why both.
  • iOS: Flutter's docs say the iOS Simulator runs only in debug mode, so upload the debug Simulator build: flutter build ios --simulator --debug, then zip Runner.app. How to make and upload it.

Make it easier#

Flutter apps with good semantics are easier for everyone, screen readers included. Give interactive widgets a label (Semantics(label: …) or the widget's own semanticLabel) and form fields a label, and tests will be faster and steadier. It is not required, but it helps.

The test#

Open the app. On the Settings tab, switch Notifications on and check
the switch shows on.
On the Chart tab, check the bar for March reads 42.
On the Form tab, enter the name "Ada" and save; check the confirmation
reads "Saved: Ada".

The same text runs on iPhone and Android.

This post is part of Mobile release testing: a guide for app teams.

Filed underiPhone and iPadAndroidHard interactions