FloatingActionButton always keeps the same position when FloatingActionButtonLocation is top. (#64746)

This commit is contained in:
GodHyum 2020-11-24 02:38:03 +09:00 committed by GitHub
parent de56c6ad72
commit 20b68c28a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 1 deletions

View file

@ -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,

View file

@ -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 {