Unverified Commit 3ec6978c authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Fix custom physics application in TabBarView (#58715)

parent 78c2defa
...@@ -1179,7 +1179,7 @@ class TabBarView extends StatefulWidget { ...@@ -1179,7 +1179,7 @@ class TabBarView extends StatefulWidget {
_TabBarViewState createState() => _TabBarViewState(); _TabBarViewState createState() => _TabBarViewState();
} }
final PageScrollPhysics _kTabBarViewPhysics = const PageScrollPhysics().applyTo(const ClampingScrollPhysics()); const PageScrollPhysics _kTabBarViewPhysics = PageScrollPhysics();
class _TabBarViewState extends State<TabBarView> { class _TabBarViewState extends State<TabBarView> {
TabController _controller; TabController _controller;
...@@ -1349,7 +1349,9 @@ class _TabBarViewState extends State<TabBarView> { ...@@ -1349,7 +1349,9 @@ class _TabBarViewState extends State<TabBarView> {
child: PageView( child: PageView(
dragStartBehavior: widget.dragStartBehavior, dragStartBehavior: widget.dragStartBehavior,
controller: _pageController, controller: _pageController,
physics: widget.physics == null ? _kTabBarViewPhysics : _kTabBarViewPhysics.applyTo(widget.physics), physics: widget.physics == null
? _kTabBarViewPhysics.applyTo(const ClampingScrollPhysics())
: _kTabBarViewPhysics.applyTo(widget.physics),
children: _childrenWithKey, children: _childrenWithKey,
), ),
); );
......
...@@ -2580,4 +2580,22 @@ void main() { ...@@ -2580,4 +2580,22 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
pageController.removeListener(pageControllerListener); pageController.removeListener(pageControllerListener);
}); });
testWidgets('Setting BouncingScrollPhysics on TabBarView does not include ClampingScrollPhysics', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/57708
await tester.pumpWidget(MaterialApp(
home: DefaultTabController(
length: 10,
child: Scaffold(
body: TabBarView(
physics: const BouncingScrollPhysics(),
children: List<Widget>.generate(10, (int i) => Center(child: Text('index $i'))),
),
),
)
));
final PageView pageView = tester.widget<PageView>(find.byType(PageView));
expect(pageView.physics.toString().contains('ClampingScrollPhysics'), isFalse);
});
} }
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