Allow changing a clipper's type (ShapeBorderClipper,_BottomAppBarClipper). (#14937)
The downcast was crashing when toggling hasNotch for BottomAppBar.
This commit is contained in:
parent
ae6ac2ca74
commit
6993b203c0
@ -152,7 +152,11 @@ class _BottomAppBarClipper extends CustomClipper<Path> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldReclip(covariant _BottomAppBarClipper oldClipper) {
|
bool shouldReclip(CustomClipper<Path> oldClipper) {
|
||||||
return oldClipper.geometry != geometry;
|
if (oldClipper.runtimeType != _BottomAppBarClipper)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
final _BottomAppBarClipper typedOldClipper = oldClipper;
|
||||||
|
return typedOldClipper.geometry != geometry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1080,8 +1080,11 @@ class ShapeBorderClipper extends CustomClipper<Path> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool shouldReclip(covariant ShapeBorderClipper oldClipper) {
|
bool shouldReclip(CustomClipper<Path> oldClipper) {
|
||||||
return oldClipper.shape != shape;
|
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));
|
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
|
// TODO(amirh): test a BottomAppBar with hasNotch=false and an overlapping
|
||||||
// FAB.
|
// FAB.
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user