Fix FlexibleSpaceBar Opacity when AppBar.toolbarHeight > ktoolbarHeight (#80453)
This commit is contained in:
parent
1912f7dea2
commit
a745fc5870
@ -305,7 +305,11 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
|
|||||||
final double fadeStart = math.max(0.0, 1.0 - kToolbarHeight / deltaExtent);
|
final double fadeStart = math.max(0.0, 1.0 - kToolbarHeight / deltaExtent);
|
||||||
const double fadeEnd = 1.0;
|
const double fadeEnd = 1.0;
|
||||||
assert(fadeStart <= fadeEnd);
|
assert(fadeStart <= fadeEnd);
|
||||||
final double opacity = 1.0 - Interval(fadeStart, fadeEnd).transform(t);
|
// If the min and max extent are the same, the app bar cannot collapse
|
||||||
|
// and the content should be visible, so opacity = 1.
|
||||||
|
final double opacity = settings.maxExtent == settings.minExtent
|
||||||
|
? 1.0
|
||||||
|
: 1.0 - Interval(fadeStart, fadeEnd).transform(t);
|
||||||
double height = settings.maxExtent;
|
double height = settings.maxExtent;
|
||||||
|
|
||||||
// StretchMode.zoomBackground
|
// StretchMode.zoomBackground
|
||||||
|
@ -121,7 +121,39 @@ void main() {
|
|||||||
expect(clipRect.size.height, minExtent);
|
expect(clipRect.size.height, minExtent);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Collpased FlexibleSpaceBar has correct semantics', (WidgetTester tester) async {
|
testWidgets('FlexibleSpaceBar.background is visible when using height other than kToolbarHeight', (WidgetTester tester) async {
|
||||||
|
// Regression test for https://github.com/flutter/flutter/issues/80451
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
toolbarHeight: 300,
|
||||||
|
flexibleSpace: const FlexibleSpaceBar(
|
||||||
|
title: Text('Title'),
|
||||||
|
background: Text('Background'),
|
||||||
|
collapseMode: CollapseMode.pin,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: CustomScrollView(
|
||||||
|
primary: true,
|
||||||
|
slivers: <Widget>[
|
||||||
|
SliverToBoxAdapter(
|
||||||
|
child: Container(
|
||||||
|
height: 1200.0,
|
||||||
|
color: Colors.orange[400],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final Opacity backgroundOpacity = tester.firstWidget(find.byType(Opacity));
|
||||||
|
expect(backgroundOpacity.opacity, 1.0);
|
||||||
|
});
|
||||||
|
|
||||||
|
testWidgets('Collapsed FlexibleSpaceBar has correct semantics', (WidgetTester tester) async {
|
||||||
final SemanticsTester semantics = SemanticsTester(tester);
|
final SemanticsTester semantics = SemanticsTester(tester);
|
||||||
const double expandedHeight = 200;
|
const double expandedHeight = 200;
|
||||||
await tester.pumpWidget(
|
await tester.pumpWidget(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user