Unverified Commit 4ad3d99b authored by Hans Muller's avatar Hans Muller Committed by GitHub

Fix a floating snapping SliverAppBar crash (#26101)

parent cb6fec10
......@@ -393,6 +393,7 @@ abstract class RenderSliverFloatingPersistentHeader extends RenderSliverPersiste
return;
if (value == null) {
_controller?.dispose();
_controller = null;
} else {
if (_snapConfiguration != null && value.vsync != _snapConfiguration.vsync)
_controller?.resync(value.vsync);
......
......@@ -1422,4 +1422,67 @@ void main() {
statusBarIconBrightness: Brightness.dark,
));
});
testWidgets('Changing SliverAppBar snap from true to false', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/17598
const double appBarHeight = 256.0;
bool snap = true;
await tester.pumpWidget(
MaterialApp(
home: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
expandedHeight: appBarHeight,
pinned: false,
floating: true,
snap: snap,
actions: <Widget>[
FlatButton(
child: const Text('snap=false'),
onPressed: () {
setState(() {
snap = false;
});
},
),
],
flexibleSpace: FlexibleSpaceBar(
background: Container(
height: appBarHeight,
color: Colors.orange,
),
),
),
SliverList(
delegate: SliverChildListDelegate(
<Widget>[
Container(height: 1200.0, color: Colors.teal),
],
),
),
],
),
);
},
),
),
);
TestGesture gesture = await tester.startGesture(const Offset(50.0, 400.0));
await gesture.moveBy(const Offset(0.0, -100.0));
await gesture.up();
await tester.tap(find.text('snap=false'));
await tester.pumpAndSettle();
gesture = await tester.startGesture(const Offset(50.0, 400.0));
await gesture.moveBy(const Offset(0.0, -100.0));
await gesture.up();
await tester.pump();
});
}
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