widgetWithImage method

Finder widgetWithImage(
  1. Type widgetType,
  2. ImageProvider<Object> image,
  3. {bool skipOffstage = true}

Looks for widgets that contain an Image descendant displaying ImageProvider image in it.

Sample code

// Suppose there is a button with an image in it:
  child: Image.file(File(filePath))

// It can be found and tapped like this:
tester.tap(find.widgetWithImage(Button, FileImage(File(filePath))));

If the skipOffstage argument is true (the default), then this skips nodes that are Offstage or that are from inactive Routes.


Finder widgetWithImage(Type widgetType, ImageProvider image, { bool skipOffstage = true }) {
  return find.ancestor(
    of: find.image(image),
    matching: find.byType(widgetType),