Committed by
GitHub
Merge pull request #671 from svenopdehipt/overlay
feat: Add overlay to scanner
Showing
1 changed file
with
16 additions
and
3 deletions
| @@ -62,6 +62,10 @@ class MobileScanner extends StatefulWidget { | @@ -62,6 +62,10 @@ class MobileScanner extends StatefulWidget { | ||
| 62 | /// Default: false | 62 | /// Default: false |
| 63 | final bool startDelay; | 63 | final bool startDelay; |
| 64 | 64 | ||
| 65 | + /// The overlay which will be painted above the scanner when has started successful. | ||
| 66 | + /// Will no be pointed when an error occurs or the scanner hasn't be started yet. | ||
| 67 | + final Widget? overlay; | ||
| 68 | + | ||
| 65 | /// Create a new [MobileScanner] using the provided [controller] | 69 | /// Create a new [MobileScanner] using the provided [controller] |
| 66 | /// and [onBarcodeDetected] callback. | 70 | /// and [onBarcodeDetected] callback. |
| 67 | const MobileScanner({ | 71 | const MobileScanner({ |
| @@ -74,6 +78,7 @@ class MobileScanner extends StatefulWidget { | @@ -74,6 +78,7 @@ class MobileScanner extends StatefulWidget { | ||
| 74 | this.placeholderBuilder, | 78 | this.placeholderBuilder, |
| 75 | this.scanWindow, | 79 | this.scanWindow, |
| 76 | this.startDelay = false, | 80 | this.startDelay = false, |
| 81 | + this.overlay, | ||
| 77 | super.key, | 82 | super.key, |
| 78 | }); | 83 | }); |
| 79 | 84 | ||
| @@ -251,15 +256,19 @@ class _MobileScannerState extends State<MobileScanner> | @@ -251,15 +256,19 @@ class _MobileScannerState extends State<MobileScanner> | ||
| 251 | _controller.updateScanWindow(scanWindow); | 256 | _controller.updateScanWindow(scanWindow); |
| 252 | } | 257 | } |
| 253 | 258 | ||
| 254 | - return ClipRect( | 259 | + return Stack( |
| 260 | + alignment: Alignment.center, | ||
| 261 | + children: [ | ||
| 262 | + ClipRect( | ||
| 255 | child: LayoutBuilder( | 263 | child: LayoutBuilder( |
| 256 | builder: (_, constraints) { | 264 | builder: (_, constraints) { |
| 257 | return SizedBox.fromSize( | 265 | return SizedBox.fromSize( |
| 258 | size: constraints.biggest, | 266 | size: constraints.biggest, |
| 259 | child: FittedBox( | 267 | child: FittedBox( |
| 260 | fit: widget.fit, | 268 | fit: widget.fit, |
| 261 | - child: SizedBox.fromSize( | ||
| 262 | - size: value.size, | 269 | + child: SizedBox( |
| 270 | + width: value.size.width, | ||
| 271 | + height: value.size.height, | ||
| 263 | child: kIsWeb | 272 | child: kIsWeb |
| 264 | ? HtmlElementView(viewType: value.webId!) | 273 | ? HtmlElementView(viewType: value.webId!) |
| 265 | : Texture(textureId: value.textureId!), | 274 | : Texture(textureId: value.textureId!), |
| @@ -268,6 +277,10 @@ class _MobileScannerState extends State<MobileScanner> | @@ -268,6 +277,10 @@ class _MobileScannerState extends State<MobileScanner> | ||
| 268 | ); | 277 | ); |
| 269 | }, | 278 | }, |
| 270 | ), | 279 | ), |
| 280 | + ), | ||
| 281 | + if (widget.overlay != null) | ||
| 282 | + widget.overlay! | ||
| 283 | + ], | ||
| 271 | ); | 284 | ); |
| 272 | }, | 285 | }, |
| 273 | ); | 286 | ); |
-
Please register or login to post a comment