run method

  1. @override
Future<void> run()
override

Implements simple_frame_app run() by listening for taps and handing off to a tapHandler() function in the class that mixes in frame_vision_app. That function would be expected to call capture() and then perform processing on the image

Implementation

@override
Future<void> run() async {
  setState(() {
    currentState = ApplicationState.running;
  });

  // listen for taps for e.g. next(1)/prev(2) content and "new capture" (3)
  _tapSubs?.cancel();
  _tapSubs = RxTap().attach(frame!.dataResponse)
    .listen((taps) async {
      _log.fine(() => 'taps: $taps');
      // call the tap handler in the implementing class
      onTap(taps);
    }
  );

  // let Frame know to subscribe for taps and send them to us
  await frame!.sendMessage(TxCode(msgCode: 0x10, value: 1));

  // prompt the user to begin tapping or other app-specific setup
  await onRun();

  // run() completes but we stay in ApplicationState.running because the tap listener is active
}