Keep system bar content usable under edge-to-edge

- Lift the QR scanner's torch and camera controls above the navigation
  bar instead of 16 px from the screen edge
- Use light system bar icons on the black QR camera and received-image
  viewer, and keep Android's contrast scrim behind three-button
  navigation for any other dark route
- Note that Flutter only applies edge-to-edge from Android 10
This commit is contained in:
zjs81 committed 2026-10-07 21:06:41 -07:00
1 parent 551bf128c6
commit 1d64399d42
3 files changed
+68 -54

No files matched your search

+26 -20
View File
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
/// A reusable QR code scanner widget that can be embedded anywhere.
@@ -150,28 +151,33 @@ class _QrScannerWidgetState extends State<QrScannerWidget>
@override
Widget build(BuildContext context) {
return Stack(
children: [
// Scanner view
MobileScanner(
controller: _controller,
onDetect: _handleDetection,
errorBuilder: (context, error) {
return _buildErrorWidget(context, error);
},
),
// The camera preview is dark, so keep the system bar icons light, and lift
// the controls above the navigation bar the app draws behind.
return AnnotatedRegion<SystemUiOverlayStyle>(
value: SystemUiOverlayStyle.light,
child: Stack(
children: [
// Scanner view
MobileScanner(
controller: _controller,
onDetect: _handleDetection,
errorBuilder: (context, error) {
return _buildErrorWidget(context, error);
},
),
// Overlay
widget.overlay ?? _buildDefaultOverlay(context),
// Overlay
widget.overlay ?? _buildDefaultOverlay(context),
// Control buttons
Positioned(
bottom: 16,
left: 0,
right: 0,
child: _buildControls(context),
),
],
// Control buttons
Positioned(
bottom: 16 + MediaQuery.viewPaddingOf(context).bottom,
left: 0,
right: 0,
child: _buildControls(context),
),
],
),
);
}