forked from firka/flutter
fix ink feature tries to get parent transformations when it is in the… (#60129)
This commit is contained in:
@@ -584,8 +584,16 @@ abstract class RenderSliverMultiBoxAdaptor extends RenderSliver
|
||||
}
|
||||
|
||||
@override
|
||||
void applyPaintTransform(RenderObject child, Matrix4 transform) {
|
||||
applyPaintTransformForBoxChild(child as RenderBox, transform);
|
||||
void applyPaintTransform(RenderBox child, Matrix4 transform) {
|
||||
if (_keepAliveBucket.containsKey(indexOf(child))) {
|
||||
// It is possible that widgets under kept alive children want to paint
|
||||
// themselves. For example, the Material widget tries to paint all
|
||||
// InkFeatures under its subtree as long as they are not disposed. In
|
||||
// such case, we give it a zero transform to prevent them from painting.
|
||||
transform.setZero();
|
||||
} else {
|
||||
applyPaintTransformForBoxChild(child, transform);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -1059,6 +1059,43 @@ void main() {
|
||||
expect(_mainTabController.index, 2);
|
||||
});
|
||||
|
||||
testWidgets('TabBarView can warp when child is kept alive and contains ink', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/57662.
|
||||
final TabController controller = TabController(
|
||||
vsync: const TestVSync(),
|
||||
length: 3,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
boilerplate(
|
||||
child: TabBarView(
|
||||
controller: controller,
|
||||
children: const <Widget>[
|
||||
Text('Page 1'),
|
||||
Text('Page 2'),
|
||||
KeepAliveInk('Page 3'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(controller.index, equals(0));
|
||||
expect(find.text('Page 1'), findsOneWidget);
|
||||
expect(find.text('Page 3'), findsNothing);
|
||||
|
||||
controller.index = 2;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Page 1'), findsNothing);
|
||||
expect(find.text('Page 3'), findsOneWidget);
|
||||
|
||||
controller.index = 0;
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Page 1'), findsOneWidget);
|
||||
expect(find.text('Page 3'), findsNothing);
|
||||
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
testWidgets('TabBarView scrolls end close to a new page with custom physics', (WidgetTester tester) async {
|
||||
final TabController tabController = TabController(
|
||||
vsync: const TestVSync(),
|
||||
@@ -2634,3 +2671,25 @@ void main() {
|
||||
expect(pageView.physics.toString().contains('ClampingScrollPhysics'), isFalse);
|
||||
});
|
||||
}
|
||||
|
||||
class KeepAliveInk extends StatefulWidget {
|
||||
const KeepAliveInk(this.title, {Key key}) : super(key: key);
|
||||
final String title;
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
return _KeepAliveInkState();
|
||||
}
|
||||
}
|
||||
|
||||
class _KeepAliveInkState extends State<KeepAliveInk> with AutomaticKeepAliveClientMixin {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return Ink(
|
||||
child: Text(widget.title),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user