Navaron Bracke

define the platform interface

  1 +import 'package:flutter/widgets.dart';
  2 +import 'package:mobile_scanner/src/enums/camera_facing.dart';
1 import 'package:mobile_scanner/src/method_channel/mobile_scanner_method_channel.dart'; 3 import 'package:mobile_scanner/src/method_channel/mobile_scanner_method_channel.dart';
  4 +import 'package:mobile_scanner/src/mobile_scanner_view_attributes.dart';
2 import 'package:plugin_platform_interface/plugin_platform_interface.dart'; 5 import 'package:plugin_platform_interface/plugin_platform_interface.dart';
3 6
4 /// The platform interface for the `mobile_scanner` plugin. 7 /// The platform interface for the `mobile_scanner` plugin.
@@ -22,4 +25,70 @@ abstract class MobileScannerPlatform extends PlatformInterface { @@ -22,4 +25,70 @@ abstract class MobileScannerPlatform extends PlatformInterface {
22 PlatformInterface.verifyToken(instance, _token); 25 PlatformInterface.verifyToken(instance, _token);
23 _instance = instance; 26 _instance = instance;
24 } 27 }
  28 +
  29 + /// Analyze a local image file for barcodes.
  30 + ///
  31 + /// Returns whether the file at the given [path] contains a barcode.
  32 + Future<bool> analyzeImage(String path) {
  33 + throw UnimplementedError('analyzeImage() has not been implemented.');
  34 + }
  35 +
  36 + /// Build the camera view for the barcode scanner.
  37 + Widget buildCameraView(covariant MobileScannerViewAttributes attributes) {
  38 + throw UnimplementedError('buildCameraView() has not been implemented.');
  39 + }
  40 +
  41 + /// Dispose of this [MobileScannerPlatform] instance.
  42 + void dispose() {
  43 + throw UnimplementedError('dispose() has not been implemented.');
  44 + }
  45 +
  46 + /// Reset the zoom scale, so that the camera is fully zoomed out.
  47 + Future<void> resetZoomScale() {
  48 + throw UnimplementedError('resetZoomScale() has not been implemented.');
  49 + }
  50 +
  51 + /// Set the zoom scale of the camera.
  52 + ///
  53 + /// The [zoomScale] must be between `0.0` and `1.0` (both inclusive).
  54 + /// A value of `0.0` indicates that the camera is fully zoomed out,
  55 + /// while `1.0` indicates that the camera is fully zoomed in.
  56 + Future<void> setZoomScale(double zoomScale) {
  57 + throw UnimplementedError('setZoomScale() has not been implemented.');
  58 + }
  59 +
  60 + /// Start scanning for barcodes.
  61 + ///
  62 + /// Upon calling this method, the necessary camera permission will be requested.
  63 + ///
  64 + /// Returns an instance of [MobileScannerViewAttributes].
  65 + Future<MobileScannerViewAttributes> start({CameraFacing? cameraDirection}) {
  66 + throw UnimplementedError('start() has not been implemented.');
  67 + }
  68 +
  69 + /// Stop the camera.
  70 + Future<void> stop() {
  71 + throw UnimplementedError('stop() has not been implemented.');
  72 + }
  73 +
  74 + /// Switch between the front and back camera.
  75 + Future<void> switchCamera() {
  76 + throw UnimplementedError('switchCamera() has not been implemented.');
  77 + }
  78 +
  79 + /// Switch the torch on or off.
  80 + ///
  81 + /// Does nothing if the device has no torch.
  82 + Future<void> toggleTorch() {
  83 + throw UnimplementedError('toggleTorch() has not been implemented.');
  84 + }
  85 +
  86 + /// Update the scan window to the given [window] rectangle.
  87 + ///
  88 + /// Any barcodes that do not intersect with the given [window] will be ignored.
  89 + ///
  90 + /// If [window] is `null`, the scan window will be reset to the full screen.
  91 + Future<void> updateScanWindow(Rect? window) {
  92 + throw UnimplementedError('updateScanWindow() has not been implemented.');
  93 + }
25 } 94 }