Added clipBehavior on TabBarView (#103166)
This commit is contained in:
@@ -1310,6 +1310,7 @@ class TabBarView extends StatefulWidget {
|
||||
this.physics,
|
||||
this.dragStartBehavior = DragStartBehavior.start,
|
||||
this.viewportFraction = 1.0,
|
||||
this.clipBehavior = Clip.hardEdge,
|
||||
}) : assert(children != null),
|
||||
assert(dragStartBehavior != null);
|
||||
|
||||
@@ -1342,6 +1343,11 @@ class TabBarView extends StatefulWidget {
|
||||
/// {@macro flutter.widgets.pageview.viewportFraction}
|
||||
final double viewportFraction;
|
||||
|
||||
/// {@macro flutter.material.Material.clipBehavior}
|
||||
///
|
||||
/// Defaults to [Clip.hardEdge].
|
||||
final Clip clipBehavior;
|
||||
|
||||
@override
|
||||
State<TabBarView> createState() => _TabBarViewState();
|
||||
}
|
||||
@@ -1531,6 +1537,7 @@ class _TabBarViewState extends State<TabBarView> {
|
||||
onNotification: _handleScrollNotification,
|
||||
child: PageView(
|
||||
dragStartBehavior: widget.dragStartBehavior,
|
||||
clipBehavior: widget.clipBehavior,
|
||||
controller: _pageController,
|
||||
physics: widget.physics == null
|
||||
? const PageScrollPhysics().applyTo(const ClampingScrollPhysics())
|
||||
|
||||
@@ -1104,6 +1104,45 @@ void main() {
|
||||
expect(pageController.viewportFraction, 1);
|
||||
});
|
||||
|
||||
testWidgets('TabBarView has clipBehavior Clip.hardEdge by default', (WidgetTester tester) async {
|
||||
final List<Widget> tabs = <Widget>[const Text('First'), const Text('Second')];
|
||||
|
||||
Widget builder() {
|
||||
return boilerplate(
|
||||
child: DefaultTabController(
|
||||
length: tabs.length,
|
||||
child: TabBarView(
|
||||
children: tabs,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(builder());
|
||||
final TabBarView tabBarView = tester.widget(find.byType(TabBarView));
|
||||
expect(tabBarView.clipBehavior, Clip.hardEdge);
|
||||
});
|
||||
|
||||
testWidgets('TabBarView sets clipBehavior correctly', (WidgetTester tester) async {
|
||||
final List<Widget> tabs = <Widget>[const Text('First'), const Text('Second')];
|
||||
|
||||
Widget builder() {
|
||||
return boilerplate(
|
||||
child: DefaultTabController(
|
||||
length: tabs.length,
|
||||
child: TabBarView(
|
||||
clipBehavior: Clip.none,
|
||||
children: tabs,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
await tester.pumpWidget(builder());
|
||||
final PageView pageView = tester.widget(find.byType(PageView));
|
||||
expect(pageView.clipBehavior, Clip.none);
|
||||
});
|
||||
|
||||
testWidgets('TabBar tap skips indicator animation when disabled in controller', (WidgetTester tester) async {
|
||||
final List<String> tabs = <String>['A', 'B'];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user