| @@ -89,6 +89,17 @@ class QRView(private val registrar: PluginRegistry.Registrar, id: Int) : | |||||
| } | } | ||||
| private fun pauseCamera() { | |||||
| if (barcodeView!!.isPreviewActive) { | |||||
| barcodeView?.pause() | |||||
| } | |||||
| } | |||||
| private fun resumeCamera() { | |||||
| if (!barcodeView!!.isPreviewActive) { | |||||
| barcodeView?.resume() | |||||
| } | |||||
| } | |||||
| private fun hasFlash(): Boolean { | private fun hasFlash(): Boolean { | ||||
| return registrar.activeContext().packageManager | return registrar.activeContext().packageManager | ||||
| @@ -154,6 +165,12 @@ class QRView(private val registrar: PluginRegistry.Registrar, id: Int) : | |||||
| "toggleFlash" -> { | "toggleFlash" -> { | ||||
| toggleFlash() | toggleFlash() | ||||
| } | } | ||||
| "pauseCamera" -> { | |||||
| pauseCamera() | |||||
| } | |||||
| "resumeCamera" -> { | |||||
| resumeCamera() | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -17,19 +17,19 @@ pool: | |||||
| steps: | steps: | ||||
| - script: | | - script: | | ||||
| cd example | cd example | ||||
| $(flutterPath)/flutter build ios | |||||
| $flutterPath/flutter build ios | |||||
| displayName: 'Test iOS -- Build' | displayName: 'Test iOS -- Build' | ||||
| env: | env: | ||||
| flutterPath: $(flutterPath) | flutterPath: $(flutterPath) | ||||
| - script: | | - script: | | ||||
| cd example | cd example | ||||
| $(flutterPath)/flutter packages get | |||||
| $(flutterPath)/flutter build apk --target-platform android-arm,android-arm64 --split-per-abi | |||||
| $flutterPath/flutter packages get | |||||
| $flutterPath/flutter build apk --target-platform android-arm,android-arm64 --split-per-abi | |||||
| displayName: 'Test Android -- Build' | displayName: 'Test Android -- Build' | ||||
| env: | env: | ||||
| flutterPath: $(flutterPath) | flutterPath: $(flutterPath) | ||||
| - script: | | - script: | | ||||
| $(flutterPath)/flutter pub pub publish --dry-run | |||||
| $flutterPath/flutter pub pub publish --dry-run | |||||
| displayName: 'Publish -- Dry Run' | displayName: 'Publish -- Dry Run' | ||||
| env: | env: | ||||
| flutterPath: $(flutterPath) | flutterPath: $(flutterPath) | ||||
| @@ -85,7 +85,31 @@ class _QRViewExampleState extends State<QRViewExample> { | |||||
| ), | ), | ||||
| ) | ) | ||||
| ], | ], | ||||
| ) | |||||
| ), | |||||
| Row( | |||||
| mainAxisAlignment: MainAxisAlignment.spaceEvenly, | |||||
| crossAxisAlignment: CrossAxisAlignment.center, | |||||
| children: <Widget>[ | |||||
| Container( | |||||
| margin: EdgeInsets.only(bottom: 8.0), | |||||
| child: RaisedButton( | |||||
| onPressed: () { | |||||
| controller?.pauseCamera(); | |||||
| }, | |||||
| child: Text('pause', style: TextStyle(fontSize: 20)), | |||||
| ), | |||||
| ), | |||||
| Container( | |||||
| margin: EdgeInsets.only(bottom: 8.0), | |||||
| child: RaisedButton( | |||||
| onPressed: () { | |||||
| controller.resumeCamera(); | |||||
| }, | |||||
| child: Text('resume', style: TextStyle(fontSize: 20)), | |||||
| ), | |||||
| ) | |||||
| ], | |||||
| ), | |||||
| ], | ], | ||||
| ), | ), | ||||
| flex: 1, | flex: 1, | ||||
| @@ -83,4 +83,20 @@ public class QRView:NSObject,FlutterPlatformView { | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| func pauseCamera() { | |||||
| if let sc: MTBBarcodeScanner = scanner { | |||||
| if sc.isScanning() { | |||||
| sc.freezeCapture() | |||||
| } | |||||
| } | |||||
| } | |||||
| func resumeCamera() { | |||||
| if let sc: MTBBarcodeScanner = scanner { | |||||
| if !sc.isScanning() { | |||||
| sc.unfreezeCapture() | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -90,4 +90,12 @@ class QRViewController { | |||||
| void toggleFlash() { | void toggleFlash() { | ||||
| channel.invokeMethod("toggleFlash"); | channel.invokeMethod("toggleFlash"); | ||||
| } | } | ||||
| void pauseCamera() { | |||||
| channel.invokeMethod("pauseCamera"); | |||||
| } | |||||
| void resumeCamera() { | |||||
| channel.invokeMethod("resumeCamera"); | |||||
| } | |||||
| } | } | ||||