import 'package:flutter/widgets.dart'; class SafeAreaBuilder extends StatelessWidget { final Widget Function(BuildContext context, EdgeInsets padding) builder; final bool maintainBottomViewPadding; const SafeAreaBuilder({ super.key, required this.builder, this.maintainBottomViewPadding = false, }); @override Widget build(BuildContext context) { assert(debugCheckHasMediaQuery(context)); final MediaQueryData data = MediaQuery.of(context); EdgeInsets padding = data.padding; // Bottom padding has been consumed - i.e. by the keyboard if (maintainBottomViewPadding) { padding = padding.copyWith(bottom: data.viewPadding.bottom); } return builder(context, padding); } }