Showing
1 changed file
with
31 additions
and
19 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 | ||
| @@ -252,24 +257,31 @@ class _MobileScannerState extends State<MobileScanner> | @@ -252,24 +257,31 @@ class _MobileScannerState extends State<MobileScanner> | ||
| 252 | _controller.updateScanWindow(scanWindow); | 257 | _controller.updateScanWindow(scanWindow); |
| 253 | } | 258 | } |
| 254 | 259 | ||
| 255 | - return ClipRect( | ||
| 256 | - child: LayoutBuilder( | ||
| 257 | - builder: (_, constraints) { | ||
| 258 | - return SizedBox.fromSize( | ||
| 259 | - size: constraints.biggest, | ||
| 260 | - child: FittedBox( | ||
| 261 | - fit: widget.fit, | ||
| 262 | - child: SizedBox( | ||
| 263 | - width: value.size.width, | ||
| 264 | - height: value.size.height, | ||
| 265 | - child: kIsWeb | ||
| 266 | - ? HtmlElementView(viewType: value.webId!) | ||
| 267 | - : Texture(textureId: value.textureId!), | ||
| 268 | - ), | ||
| 269 | - ), | ||
| 270 | - ); | ||
| 271 | - }, | ||
| 272 | - ), | 260 | + return Stack( |
| 261 | + alignment: Alignment.center, | ||
| 262 | + children: [ | ||
| 263 | + ClipRect( | ||
| 264 | + child: LayoutBuilder( | ||
| 265 | + builder: (_, constraints) { | ||
| 266 | + return SizedBox.fromSize( | ||
| 267 | + size: constraints.biggest, | ||
| 268 | + child: FittedBox( | ||
| 269 | + fit: widget.fit, | ||
| 270 | + child: SizedBox( | ||
| 271 | + width: value.size.width, | ||
| 272 | + height: value.size.height, | ||
| 273 | + child: kIsWeb | ||
| 274 | + ? HtmlElementView(viewType: value.webId!) | ||
| 275 | + : Texture(textureId: value.textureId!), | ||
| 276 | + ), | ||
| 277 | + ), | ||
| 278 | + ); | ||
| 279 | + }, | ||
| 280 | + ), | ||
| 281 | + ), | ||
| 282 | + if (widget.overlay != null) | ||
| 283 | + widget.overlay! | ||
| 284 | + ], | ||
| 273 | ); | 285 | ); |
| 274 | }, | 286 | }, |
| 275 | ); | 287 | ); |
| @@ -286,4 +298,4 @@ class _MobileScannerState extends State<MobileScanner> | @@ -286,4 +298,4 @@ class _MobileScannerState extends State<MobileScanner> | ||
| 286 | _controller.dispose(); | 298 | _controller.dispose(); |
| 287 | super.dispose(); | 299 | super.dispose(); |
| 288 | } | 300 | } |
| 289 | -} | 301 | +} |
-
Please register or login to post a comment