run method

  1. @override
void run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
void run() async {
  final googleVision = await GoogleVision.withJwt(
      globalResults!['credential-file'],
      'https://www.googleapis.com/auth/cloud-vision');

  final painter = Painter.fromFilePath(argResults!['image-file']);

  final requests = AnnotationRequests(requests: [
    AnnotationRequest(
      image: Image(painter: painter),
      features: [Feature(type: 'SAFE_SEARCH_DETECTION')],
    )
  ]);

  final annotatedResponses = await googleVision.annotate(requests: requests);

  print(annotatedResponses.responses);
}