import 'package:flutter/material.dart'; class OutsideDimMask extends StatelessWidget { final double opacity; const OutsideDimMask({super.key, this.opacity = 0.6}); @override Widget build(BuildContext context) { const a5Ratio = 148 / 210; return LayoutBuilder( builder: (context, constraints) { final width = constraints.maxWidth; final height = constraints.maxHeight; double frameWidth; double frameHeight; if (width / height > a5Ratio) { frameHeight = height; frameWidth = height * a5Ratio; } else { frameWidth = width; frameHeight = width / a5Ratio; } final left = (width - frameWidth) / 2; final top = (height - frameHeight) / 2; return Stack( children: [ // Top Positioned( left: 0, right: 0, top: 0, height: top, child: Container(color: Colors.black.withOpacity(opacity)), ), // Bottom Positioned( left: 0, right: 0, bottom: 0, height: top, child: Container(color: Colors.black.withOpacity(opacity)), ), // Left Positioned( left: 0, top: top, width: left, height: frameHeight, child: Container(color: Colors.black.withOpacity(opacity)), ), // Right Positioned( right: 0, top: top, width: left, height: frameHeight, child: Container(color: Colors.black.withOpacity(opacity)), ), ], ); }, ); } }