Unverified Commit 6993b203 authored by amirh's avatar amirh Committed by GitHub

Allow changing a clipper's type (ShapeBorderClipper,_BottomAppBarClipper). (#14937)

The downcast was crashing when toggling hasNotch for BottomAppBar.
parent ae6ac2ca
......@@ -152,7 +152,11 @@ class _BottomAppBarClipper extends CustomClipper<Path> {
}
@override
bool shouldReclip(covariant _BottomAppBarClipper oldClipper) {
return oldClipper.geometry != geometry;
bool shouldReclip(CustomClipper<Path> oldClipper) {
if (oldClipper.runtimeType != _BottomAppBarClipper)
return true;
final _BottomAppBarClipper typedOldClipper = oldClipper;
return typedOldClipper.geometry != geometry;
}
}
......@@ -1080,8 +1080,11 @@ class ShapeBorderClipper extends CustomClipper<Path> {
}
@override
bool shouldReclip(covariant ShapeBorderClipper oldClipper) {
return oldClipper.shape != shape;
bool shouldReclip(CustomClipper<Path> oldClipper) {
if (oldClipper.runtimeType != ShapeBorderClipper)
return true;
final ShapeBorderClipper typedOldClipper = oldClipper;
return typedOldClipper.shape != shape;
}
}
......
......@@ -86,6 +86,40 @@ void main() {
expect(physicalShape.color, const Color(0xff0000ff));
});
// This is a regression test for a bug we had where toggling hasNotch
// will crash, as the shouldReclip method of ShapeBorderClipper or
// _BottomAppBarClipper will try an illegal downcast.
testWidgets('toggle hasNotch', (WidgetTester tester) async {
await tester.pumpWidget(
new MaterialApp(
home: const Scaffold(
bottomNavigationBar: const BottomAppBar(
hasNotch: true,
),
),
),
);
await tester.pumpWidget(
new MaterialApp(
home: const Scaffold(
bottomNavigationBar: const BottomAppBar(
hasNotch: false,
),
),
),
);
await tester.pumpWidget(
new MaterialApp(
home: const Scaffold(
bottomNavigationBar: const BottomAppBar(
hasNotch: true,
),
),
),
);
});
// TODO(amirh): test a BottomAppBar with hasNotch=false and an overlapping
// FAB.
//
......
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