Showing
1 changed file
with
31 additions
and
35 deletions
| @@ -70,44 +70,40 @@ class _MobileScannerState extends State<MobileScanner> | @@ -70,44 +70,40 @@ class _MobileScannerState extends State<MobileScanner> | ||
| 70 | 70 | ||
| 71 | @override | 71 | @override |
| 72 | Widget build(BuildContext context) { | 72 | Widget build(BuildContext context) { |
| 73 | - return LayoutBuilder( | ||
| 74 | - builder: (context, BoxConstraints constraints) { | ||
| 75 | - return ValueListenableBuilder( | ||
| 76 | - valueListenable: controller.args, | ||
| 77 | - builder: (context, value, child) { | ||
| 78 | - value = value as MobileScannerArguments?; | ||
| 79 | - if (value == null) { | ||
| 80 | - return Container(color: Colors.black); | 73 | + return ValueListenableBuilder( |
| 74 | + valueListenable: controller.args, | ||
| 75 | + builder: (context, value, child) { | ||
| 76 | + value = value as MobileScannerArguments?; | ||
| 77 | + if (value == null) { | ||
| 78 | + return Container(color: Colors.black); | ||
| 79 | + } else { | ||
| 80 | + controller.barcodes.listen((barcode) { | ||
| 81 | + if (!widget.allowDuplicates) { | ||
| 82 | + if (lastScanned != barcode.rawValue) { | ||
| 83 | + lastScanned = barcode.rawValue; | ||
| 84 | + widget.onDetect(barcode, value! as MobileScannerArguments); | ||
| 85 | + } | ||
| 81 | } else { | 86 | } else { |
| 82 | - controller.barcodes.listen((barcode) { | ||
| 83 | - if (!widget.allowDuplicates) { | ||
| 84 | - if (lastScanned != barcode.rawValue) { | ||
| 85 | - lastScanned = barcode.rawValue; | ||
| 86 | - widget.onDetect(barcode, value! as MobileScannerArguments); | ||
| 87 | - } | ||
| 88 | - } else { | ||
| 89 | - widget.onDetect(barcode, value! as MobileScannerArguments); | ||
| 90 | - } | ||
| 91 | - }); | ||
| 92 | - return ClipRect( | 87 | + widget.onDetect(barcode, value! as MobileScannerArguments); |
| 88 | + } | ||
| 89 | + }); | ||
| 90 | + return ClipRect( | ||
| 91 | + child: SizedBox( | ||
| 92 | + width: MediaQuery.of(context).size.width, | ||
| 93 | + height: MediaQuery.of(context).size.height, | ||
| 94 | + child: FittedBox( | ||
| 95 | + fit: widget.fit, | ||
| 93 | child: SizedBox( | 96 | child: SizedBox( |
| 94 | - width: MediaQuery.of(context).size.width, | ||
| 95 | - height: MediaQuery.of(context).size.height, | ||
| 96 | - child: FittedBox( | ||
| 97 | - fit: widget.fit, | ||
| 98 | - child: SizedBox( | ||
| 99 | - width: value.size.width, | ||
| 100 | - height: value.size.height, | ||
| 101 | - child: kIsWeb | ||
| 102 | - ? HtmlElementView(viewType: value.webId!) | ||
| 103 | - : Texture(textureId: value.textureId!), | ||
| 104 | - ), | ||
| 105 | - ), | 97 | + width: value.size.width, |
| 98 | + height: value.size.height, | ||
| 99 | + child: kIsWeb | ||
| 100 | + ? HtmlElementView(viewType: value.webId!) | ||
| 101 | + : Texture(textureId: value.textureId!), | ||
| 106 | ), | 102 | ), |
| 107 | - ); | ||
| 108 | - } | ||
| 109 | - }, | ||
| 110 | - ); | 103 | + ), |
| 104 | + ), | ||
| 105 | + ); | ||
| 106 | + } | ||
| 111 | }, | 107 | }, |
| 112 | ); | 108 | ); |
| 113 | } | 109 | } |
-
Please register or login to post a comment