You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
733 B
Dart

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);
}
}