Skip to content

Commit ec3a09f

Browse files
committed
add missing argument
1 parent efc8379 commit ec3a09f

3 files changed

Lines changed: 105 additions & 7 deletions

File tree

‎packages/flutter/lib/src/widgets/scroll_physics.dart‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,25 +92,28 @@ class ScrollPhysics {
9292
const ScrollPhysics({this.parent});
9393

9494
/// Creates a [AlwaysScrollableScrollPhysics] instance.
95-
const factory ScrollPhysics.alwaysScrollable() = AlwaysScrollableScrollPhysics;
95+
const factory ScrollPhysics.alwaysScrollable({ScrollPhysics? parent}) =
96+
AlwaysScrollableScrollPhysics;
9697

9798
/// Creates a [BouncingScrollPhysics] instance.
98-
const factory ScrollPhysics.bouncing() = BouncingScrollPhysics;
99+
const factory ScrollPhysics.bouncing({ScrollPhysics? parent}) = BouncingScrollPhysics;
99100

100101
/// Creates a [ClampingScrollPhysics] instance.
101-
const factory ScrollPhysics.clamping() = ClampingScrollPhysics;
102+
const factory ScrollPhysics.clamping({ScrollPhysics? parent}) = ClampingScrollPhysics;
102103

103104
/// Creates a [FixedExtentScrollPhysics] instance.
104-
const factory ScrollPhysics.fixedExtent() = FixedExtentScrollPhysics;
105+
const factory ScrollPhysics.fixedExtent({ScrollPhysics? parent}) = FixedExtentScrollPhysics;
105106

106107
/// Creates a [NeverScrollableScrollPhysics] instance.
107-
const factory ScrollPhysics.neverScrollable() = NeverScrollableScrollPhysics;
108+
const factory ScrollPhysics.neverScrollable({ScrollPhysics? parent}) =
109+
NeverScrollableScrollPhysics;
108110

109111
/// Creates a [PageScrollPhysics] instance.
110-
const factory ScrollPhysics.page() = PageScrollPhysics;
112+
const factory ScrollPhysics.page({ScrollPhysics? parent}) = PageScrollPhysics;
111113

112114
/// Creates a [RangeMaintainingScrollPhysics] instance.
113-
const factory ScrollPhysics.rangeMaintaining() = RangeMaintainingScrollPhysics;
115+
const factory ScrollPhysics.rangeMaintaining({ScrollPhysics? parent}) =
116+
RangeMaintainingScrollPhysics;
114117

115118
/// If non-null, determines the default behavior for each method.
116119
///

‎packages/flutter/test/widgets/list_wheel_scroll_view_test.dart‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,5 +2075,22 @@ void main() {
20752075
tester.widget<ListWheelScrollView>(find.byType(ListWheelScrollView)).physics,
20762076
isA<FixedExtentScrollPhysics>(),
20772077
);
2078+
expect(
2079+
tester.widget<ListWheelScrollView>(find.byType(ListWheelScrollView)).physics?.parent,
2080+
isNull,
2081+
);
2082+
2083+
await tester.pumpWidget(
2084+
ListWheelScrollView(
2085+
itemExtent: 20.0,
2086+
physics: const .fixedExtent(parent: ClampingScrollPhysics()),
2087+
children: <Widget>[for (int i = 0; i < 20; i++) const SizedBox()],
2088+
),
2089+
);
2090+
2091+
expect(
2092+
tester.widget<ListWheelScrollView>(find.byType(ListWheelScrollView)).physics?.parent,
2093+
isA<ClampingScrollPhysics>(),
2094+
);
20782095
});
20792096
}

‎packages/flutter/test/widgets/scroll_physics_test.dart‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,19 @@ FlutterError
592592
tester.widget<Scrollable>(find.byType(Scrollable)).physics,
593593
isA<AlwaysScrollableScrollPhysics>(),
594594
);
595+
expect(tester.widget<Scrollable>(find.byType(Scrollable)).physics?.parent, isNull);
596+
597+
await tester.pumpWidget(
598+
Directionality(
599+
textDirection: .ltr,
600+
child: ListView(physics: const .alwaysScrollable(parent: ClampingScrollPhysics())),
601+
),
602+
);
603+
604+
expect(
605+
tester.widget<Scrollable>(find.byType(Scrollable)).physics?.parent,
606+
isA<ClampingScrollPhysics>(),
607+
);
595608
});
596609

597610
testWidgets('ScrollPhysics supports shorthands for BouncingScrollPhysics', (
@@ -608,6 +621,19 @@ FlutterError
608621
tester.widget<Scrollable>(find.byType(Scrollable)).physics,
609622
isA<BouncingScrollPhysics>(),
610623
);
624+
expect(tester.widget<Scrollable>(find.byType(Scrollable)).physics?.parent, isNull);
625+
626+
await tester.pumpWidget(
627+
Directionality(
628+
textDirection: .ltr,
629+
child: ListView(physics: const .bouncing(parent: ClampingScrollPhysics())),
630+
),
631+
);
632+
633+
expect(
634+
tester.widget<Scrollable>(find.byType(Scrollable)).physics?.parent,
635+
isA<ClampingScrollPhysics>(),
636+
);
611637
});
612638

613639
testWidgets('ScrollPhysics supports shorthands for ClampingScrollPhysics', (
@@ -624,6 +650,19 @@ FlutterError
624650
tester.widget<Scrollable>(find.byType(Scrollable)).physics,
625651
isA<ClampingScrollPhysics>(),
626652
);
653+
expect(tester.widget<Scrollable>(find.byType(Scrollable)).physics?.parent, isNull);
654+
655+
await tester.pumpWidget(
656+
Directionality(
657+
textDirection: .ltr,
658+
child: ListView(physics: const .clamping(parent: ClampingScrollPhysics())),
659+
),
660+
);
661+
662+
expect(
663+
tester.widget<Scrollable>(find.byType(Scrollable)).physics?.parent,
664+
isA<ClampingScrollPhysics>(),
665+
);
627666
});
628667

629668
testWidgets('ScrollPhysics supports shorthands for NeverScrollableScrollPhysics', (
@@ -640,6 +679,19 @@ FlutterError
640679
tester.widget<Scrollable>(find.byType(Scrollable)).physics,
641680
isA<NeverScrollableScrollPhysics>(),
642681
);
682+
expect(tester.widget<Scrollable>(find.byType(Scrollable)).physics?.parent, isNull);
683+
684+
await tester.pumpWidget(
685+
Directionality(
686+
textDirection: .ltr,
687+
child: ListView(physics: const .neverScrollable(parent: ClampingScrollPhysics())),
688+
),
689+
);
690+
691+
expect(
692+
tester.widget<Scrollable>(find.byType(Scrollable)).physics?.parent,
693+
isA<ClampingScrollPhysics>(),
694+
);
643695
});
644696

645697
testWidgets('ScrollPhysics supports shorthands for PageScrollPhysics', (
@@ -653,6 +705,19 @@ FlutterError
653705
);
654706

655707
expect(tester.widget<Scrollable>(find.byType(Scrollable)).physics, isA<PageScrollPhysics>());
708+
expect(tester.widget<Scrollable>(find.byType(Scrollable)).physics?.parent, isNull);
709+
710+
await tester.pumpWidget(
711+
Directionality(
712+
textDirection: .ltr,
713+
child: ListView(physics: const .page(parent: ClampingScrollPhysics())),
714+
),
715+
);
716+
717+
expect(
718+
tester.widget<Scrollable>(find.byType(Scrollable)).physics?.parent,
719+
isA<ClampingScrollPhysics>(),
720+
);
656721
});
657722

658723
testWidgets('ScrollPhysics supports shorthands for RangeMaintainingScrollPhysics', (
@@ -669,6 +734,19 @@ FlutterError
669734
tester.widget<Scrollable>(find.byType(Scrollable)).physics,
670735
isA<RangeMaintainingScrollPhysics>(),
671736
);
737+
expect(tester.widget<Scrollable>(find.byType(Scrollable)).physics?.parent, isNull);
738+
739+
await tester.pumpWidget(
740+
Directionality(
741+
textDirection: .ltr,
742+
child: ListView(physics: const .rangeMaintaining(parent: ClampingScrollPhysics())),
743+
),
744+
);
745+
746+
expect(
747+
tester.widget<Scrollable>(find.byType(Scrollable)).physics?.parent,
748+
isA<ClampingScrollPhysics>(),
749+
);
672750
});
673751
}
674752

0 commit comments

Comments
 (0)