Unverified Commit 355ebef5 authored by Chris Bracken's avatar Chris Bracken Committed by GitHub

Remove bottom padding in SliverAppBar (#13471)

Removes bottom padding from the child AppBar in SliverAppBar. Scaffold
already does this for its own app bars, but sliver app bars in the body
should also apply the bottom padding removal.

Fixes flutter/flutter#13458
parent 186d1e9b
...@@ -954,31 +954,35 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix ...@@ -954,31 +954,35 @@ class _SliverAppBarState extends State<SliverAppBar> with TickerProviderStateMix
final double collapsedHeight = (widget.pinned && widget.floating && widget.bottom != null) final double collapsedHeight = (widget.pinned && widget.floating && widget.bottom != null)
? widget.bottom.preferredSize.height + topPadding : null; ? widget.bottom.preferredSize.height + topPadding : null;
return new SliverPersistentHeader( return new MediaQuery.removePadding(
floating: widget.floating, context: context,
pinned: widget.pinned, removeBottom: true,
delegate: new _SliverAppBarDelegate( child: new SliverPersistentHeader(
leading: widget.leading,
automaticallyImplyLeading: widget.automaticallyImplyLeading,
title: widget.title,
actions: widget.actions,
flexibleSpace: widget.flexibleSpace,
bottom: widget.bottom,
elevation: widget.elevation,
forceElevated: widget.forceElevated,
backgroundColor: widget.backgroundColor,
brightness: widget.brightness,
iconTheme: widget.iconTheme,
textTheme: widget.textTheme,
primary: widget.primary,
centerTitle: widget.centerTitle,
titleSpacing: widget.titleSpacing,
expandedHeight: widget.expandedHeight,
collapsedHeight: collapsedHeight,
topPadding: topPadding,
floating: widget.floating, floating: widget.floating,
pinned: widget.pinned, pinned: widget.pinned,
snapConfiguration: _snapConfiguration, delegate: new _SliverAppBarDelegate(
leading: widget.leading,
automaticallyImplyLeading: widget.automaticallyImplyLeading,
title: widget.title,
actions: widget.actions,
flexibleSpace: widget.flexibleSpace,
bottom: widget.bottom,
elevation: widget.elevation,
forceElevated: widget.forceElevated,
backgroundColor: widget.backgroundColor,
brightness: widget.brightness,
iconTheme: widget.iconTheme,
textTheme: widget.textTheme,
primary: widget.primary,
centerTitle: widget.centerTitle,
titleSpacing: widget.titleSpacing,
expandedHeight: widget.expandedHeight,
collapsedHeight: collapsedHeight,
topPadding: topPadding,
floating: widget.floating,
pinned: widget.pinned,
snapConfiguration: _snapConfiguration,
),
), ),
); );
} }
......
...@@ -1145,4 +1145,34 @@ void main() { ...@@ -1145,4 +1145,34 @@ void main() {
expect(tester.getTopLeft(find.byKey(titleKey)), const Offset(420.0, 100.0)); expect(tester.getTopLeft(find.byKey(titleKey)), const Offset(420.0, 100.0));
expect(tester.getTopLeft(find.byKey(trailingKey)), const Offset(4.0, 100.0)); expect(tester.getTopLeft(find.byKey(trailingKey)), const Offset(4.0, 100.0));
}); });
testWidgets('SliverAppBar positioning of leading and trailing widgets with bottom padding', (WidgetTester tester) async {
const MediaQueryData topPadding100 = const MediaQueryData(padding: const EdgeInsets.only(top: 100.0, bottom: 50.0));
final Key leadingKey = new UniqueKey();
final Key titleKey = new UniqueKey();
final Key trailingKey = new UniqueKey();
await tester.pumpWidget(
new Directionality(
textDirection: TextDirection.rtl,
child: new MediaQuery(
data: topPadding100,
child: new CustomScrollView(
primary: true,
slivers: <Widget>[
new SliverAppBar(
leading: new Placeholder(key: leadingKey),
title: new Placeholder(key: titleKey),
actions: <Widget>[ new Placeholder(key: trailingKey) ],
),
],
),
),
),
);
expect(tester.getRect(find.byType(AppBar)), new Rect.fromLTRB(0.0, 0.0, 800.00, 100.0 + 56.0));
expect(tester.getRect(find.byKey(leadingKey)), new Rect.fromLTRB(800.0 - 56.0, 100.0, 800.0, 100.0 + 56.0));
expect(tester.getRect(find.byKey(trailingKey)), new Rect.fromLTRB(4.0, 100.0, 400.0 + 4.0, 100.0 + 56.0));
});
} }
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