title: How do I stub a function that does not belong to a class, during a widget test?
body: <p>I am creating a flutter app that uses the native camera to take a photo, using the official flutter camera package (<a href="https://pub.dev/packages/camera" rel="noreferrer">https://pub.dev/packages/camera</a>). The app opens up a modal that loads a <code>CameraPreview</code> based on the the result of the <code>availableCameras</code> function from the package and a <code>FloatingActionButton</code> which takes a photo when pressed. While creating a widget test for this modal, I can not figure out how to stub the <code>availableCameras</code> function to return what I want during tests.</p>
  
  <p>I tried using the Mockito testing package, but this only supports mocking classes. Since this function does not belong to a class, I cannot mock it.</p>
  
  <p>The <code>availableCameras</code> function returns a list of cameras that the device has. I want to be able to control what comes back from this function, so that I may test how my widget reacts to different cameras. What is the proper way to have this function return what I want during a widget test?</p>