Skip to content

SafeResizedWidget | new widget #42

@a-givertzman

Description

@a-givertzman

Add this widget to lib to customize target window size in the full screen mode

class SafeResizedWidget extends StatelessWidget {
  final Widget _child;
  final double _targetWidth;
  final double _targetHeight;
  final double _opacity;
  ///
  const SafeResizedWidget({
    super.key,
    required Widget child,
    required double targetWidth,
    required double targetHeight,
    double opacity = 0.5,
  }) : 
    _child = child,
    _targetWidth = targetWidth,
    _targetHeight = targetHeight,
    _opacity = opacity;
  ///
  @override
  Widget build(BuildContext context) {
    final dw = (MediaQuery.of(context).size.width - _targetWidth) / 2;
    final dh = (MediaQuery.of(context).size.height - _targetHeight) / 2;
    return Container(
      color: Theme.of(context).colorScheme.background.withOpacity(_opacity),
      child: SafeArea(
        minimum: EdgeInsets.symmetric(
          horizontal: dw,
          vertical: dh,
        ),
        child: _child,
      ),
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    🟠 Priority 2

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions