Unverified Commit 20b68c28 authored by GodHyum's avatar GodHyum Committed by GitHub

FloatingActionButton always keeps the same position when...

FloatingActionButton always keeps the same position when FloatingActionButtonLocation is top. (#64746)
parent de56c6ad
......@@ -959,7 +959,9 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate {
final ScaffoldPrelayoutGeometry currentGeometry = ScaffoldPrelayoutGeometry(
bottomSheetSize: bottomSheetSize,
contentBottom: contentBottom,
contentTop: contentTop,
/// [appBarHeight] should be used instead of [contentTop] because
/// ScaffoldPrelayoutGeometry.contentTop must not be affected by [extendBodyBehindAppBar].
contentTop: appBarHeight,
floatingActionButtonSize: fabSize,
minInsets: minInsets,
scaffoldSize: size,
......
......@@ -2031,6 +2031,36 @@ void main() {
);
await tester.pumpAndSettle();
});
testWidgets('FloatingActionButton always keeps the same position regardless of extendBodyBehindAppBar', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
home: Scaffold(
appBar: AppBar(),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: const Icon(Icons.add),
),
floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
extendBodyBehindAppBar: false,
),
));
final Offset defaultOffset = tester.getCenter(find.byType(FloatingActionButton));
await tester.pumpWidget(MaterialApp(
home: Scaffold(
appBar: AppBar(),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: const Icon(Icons.add),
),
floatingActionButtonLocation: FloatingActionButtonLocation.endTop,
extendBodyBehindAppBar: true,
),
));
final Offset extendedBodyOffset = tester.getCenter(find.byType(FloatingActionButton));
expect(defaultOffset.dy, extendedBodyOffset.dy);
});
});
testWidgets('ScaffoldMessenger.maybeOf can return null if not found', (WidgetTester tester) async {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment