use MediaQuery.sizeOf() instead of the topmost layout builder
Showing
1 changed file
with
36 additions
and
38 deletions
| @@ -232,45 +232,43 @@ class _MobileScannerState extends State<MobileScanner> | @@ -232,45 +232,43 @@ class _MobileScannerState extends State<MobileScanner> | ||
| 232 | 232 | ||
| 233 | @override | 233 | @override |
| 234 | Widget build(BuildContext context) { | 234 | Widget build(BuildContext context) { |
| 235 | - return LayoutBuilder( | ||
| 236 | - builder: (context, constraints) { | ||
| 237 | - return ValueListenableBuilder<MobileScannerArguments?>( | ||
| 238 | - valueListenable: _controller.startArguments, | ||
| 239 | - builder: (context, value, child) { | ||
| 240 | - if (value == null) { | ||
| 241 | - return _buildPlaceholderOrError(context, child); | ||
| 242 | - } | ||
| 243 | - | ||
| 244 | - if (widget.scanWindow != null && scanWindow == null) { | ||
| 245 | - scanWindow = calculateScanWindowRelativeToTextureInPercentage( | ||
| 246 | - widget.fit, | ||
| 247 | - widget.scanWindow!, | ||
| 248 | - value.size, | ||
| 249 | - constraints.biggest, | ||
| 250 | - ); | 235 | + final Size size = MediaQuery.sizeOf(context); |
| 236 | + | ||
| 237 | + return ValueListenableBuilder<MobileScannerArguments?>( | ||
| 238 | + valueListenable: _controller.startArguments, | ||
| 239 | + builder: (context, value, child) { | ||
| 240 | + if (value == null) { | ||
| 241 | + return _buildPlaceholderOrError(context, child); | ||
| 242 | + } | ||
| 243 | + | ||
| 244 | + if (widget.scanWindow != null && scanWindow == null) { | ||
| 245 | + scanWindow = calculateScanWindowRelativeToTextureInPercentage( | ||
| 246 | + widget.fit, | ||
| 247 | + widget.scanWindow!, | ||
| 248 | + value.size, | ||
| 249 | + size, | ||
| 250 | + ); | ||
| 251 | + | ||
| 252 | + _controller.updateScanWindow(scanWindow); | ||
| 253 | + } | ||
| 251 | 254 | ||
| 252 | - _controller.updateScanWindow(scanWindow); | ||
| 253 | - } | ||
| 254 | - | ||
| 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.fromSize( | ||
| 263 | - size: value.size, | ||
| 264 | - child: kIsWeb | ||
| 265 | - ? HtmlElementView(viewType: value.webId!) | ||
| 266 | - : Texture(textureId: value.textureId!), | ||
| 267 | - ), | ||
| 268 | - ), | ||
| 269 | - ); | ||
| 270 | - }, | ||
| 271 | - ), | ||
| 272 | - ); | ||
| 273 | - }, | 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.fromSize( | ||
| 263 | + size: value.size, | ||
| 264 | + child: kIsWeb | ||
| 265 | + ? HtmlElementView(viewType: value.webId!) | ||
| 266 | + : Texture(textureId: value.textureId!), | ||
| 267 | + ), | ||
| 268 | + ), | ||
| 269 | + ); | ||
| 270 | + }, | ||
| 271 | + ), | ||
| 274 | ); | 272 | ); |
| 275 | }, | 273 | }, |
| 276 | ); | 274 | ); |
-
Please register or login to post a comment