using the system back button from flutter driver


How can I use the system back button in an integration test?

So I’m using flutter and am writing integration tests, in most circumstances I can use the AppBar navigation, finding it by tool tip looks like this :


But one of my tests opens a web page, after this opens I need to carry on with my tests which means I need to press the system back button, is this possible?

many thanks


If you have adb installed on your machine, you can run a command to perform the backpress using a keyevent:

import 'dart:io';
  <String>['shell', 'input', 'keyevent', 'KEYCODE_BACK'], 
  runInShell: true,

Answered By – Miguel Beltran

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *