Skip to content

Commit 163958c

Browse files
committed
Fix scroll physics and always scrollable option.
1 parent 840bf25 commit 163958c

13 files changed

+79
-37
lines changed

lib/src/api/mixins.dart

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ enum ScrollPhysicsC {
940940
/// the scroll view to its normal range when released.
941941
///
942942
/// See [AlwaysScrollableScrollPhysics] in Flutter for more details.
943-
alwaysScrollableScrollPhysics,
943+
platformDependent,
944944

945945
/// Scroll physics for environments that allow the scroll offset to go beyond
946946
/// the bounds of the content, but then bounce the content back to the edge of
@@ -981,8 +981,8 @@ enum ScrollPhysicsC {
981981
return 'Clamping';
982982
case ScrollPhysicsC.neverScrollableScrollPhysics:
983983
return 'Never Scrollable';
984-
case ScrollPhysicsC.alwaysScrollableScrollPhysics:
985-
return 'Always Scrollable';
984+
case ScrollPhysicsC.platformDependent:
985+
return 'Platform Dependent';
986986
}
987987
}
988988
}
@@ -1035,6 +1035,7 @@ mixin ScrollableMixin on BaseNode {
10351035
late bool primary;
10361036

10371037
/// Physics to use for the scrollable.
1038+
@JsonKey(unknownEnumValue: ScrollPhysicsC.platformDependent)
10381039
late ScrollPhysicsC physics;
10391040

10401041
/// Defines how a [ScrollView] should dismiss the on-screen keyboard.
@@ -1044,6 +1045,9 @@ mixin ScrollableMixin on BaseNode {
10441045
/// code-gen and transformers.
10451046
late bool useFlutterListView;
10461047

1048+
/// Whether to use AlwaysScrollableScrollPhysics or not.
1049+
late bool shouldAlwaysScroll;
1050+
10471051
/// Sets the properties of this mixin.
10481052
void setScrollableMixin({
10491053
required bool isScrollable,
@@ -1054,6 +1058,7 @@ mixin ScrollableMixin on BaseNode {
10541058
required bool shrinkWrap,
10551059
required ScrollViewKeyboardDismissBehaviorC keyboardDismissBehavior,
10561060
required bool useFlutterListView,
1061+
required bool shouldAlwaysScroll,
10571062
}) {
10581063
this.isScrollable = isScrollable;
10591064
this.scrollDirection = scrollDirection;
@@ -1062,6 +1067,7 @@ mixin ScrollableMixin on BaseNode {
10621067
this.primary = primary;
10631068
this.keyboardDismissBehavior = keyboardDismissBehavior;
10641069
this.useFlutterListView = useFlutterListView;
1070+
this.shouldAlwaysScroll = shouldAlwaysScroll;
10651071
}
10661072
}
10671073

lib/src/api/nodes/canvas_node.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,13 @@ class CanvasNode extends ParentNode
9494
bool isScrollable = false,
9595
AxisC scrollDirection = AxisC.vertical,
9696
bool reverse = false,
97-
ScrollPhysicsC physics = ScrollPhysicsC.alwaysScrollableScrollPhysics,
97+
ScrollPhysicsC physics = ScrollPhysicsC.platformDependent,
9898
bool primary = true,
9999
bool shrinkWrap = false,
100100
ScrollViewKeyboardDismissBehaviorC keyboardDismissBehavior =
101101
ScrollViewKeyboardDismissBehaviorC.manual,
102102
bool useFlutterListView = false,
103+
bool shouldAlwaysScroll = true,
103104

104105
// Custom properties.
105106
required this.properties,
@@ -123,6 +124,7 @@ class CanvasNode extends ParentNode
123124
shrinkWrap: shrinkWrap,
124125
keyboardDismissBehavior: keyboardDismissBehavior,
125126
useFlutterListView: useFlutterListView,
127+
shouldAlwaysScroll: shouldAlwaysScroll,
126128
);
127129
}
128130

lib/src/api/nodes/canvas_node.g.dart

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/nodes/frame_node.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ class FrameNode extends DefaultShapeNode
6363
bool isScrollable = false,
6464
AxisC scrollDirection = AxisC.vertical,
6565
bool reverse = false,
66-
ScrollPhysicsC physics = ScrollPhysicsC.alwaysScrollableScrollPhysics,
66+
ScrollPhysicsC physics = ScrollPhysicsC.platformDependent,
6767
bool primary = true,
6868
bool shrinkWrap = false,
6969
ScrollViewKeyboardDismissBehaviorC keyboardDismissBehavior =
7070
ScrollViewKeyboardDismissBehaviorC.manual,
7171
bool useFlutterListView = false,
72+
bool shouldAlwaysScroll = true,
7273

7374
// [PortalMixin] properties.
7475
String? canvasID,
@@ -92,6 +93,7 @@ class FrameNode extends DefaultShapeNode
9293
shrinkWrap: shrinkWrap,
9394
keyboardDismissBehavior: keyboardDismissBehavior,
9495
useFlutterListView: useFlutterListView,
96+
shouldAlwaysScroll: shouldAlwaysScroll,
9597
);
9698

9799
setPortalMixin(

lib/src/api/nodes/frame_node.g.dart

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/nodes/list_view_node.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ class ListViewNode extends SinglePlaceholderNode
6161
// [ScrollableMixin] properties.
6262
AxisC scrollDirection = AxisC.vertical,
6363
bool reverse = false,
64-
ScrollPhysicsC physics = ScrollPhysicsC.alwaysScrollableScrollPhysics,
64+
ScrollPhysicsC physics = ScrollPhysicsC.platformDependent,
6565
bool primary = false,
6666
ScrollViewKeyboardDismissBehaviorC keyboardDismissBehavior =
6767
ScrollViewKeyboardDismissBehaviorC.manual,
68+
bool shouldAlwaysScroll = true,
6869
}) : super(
6970
children: [],
7071
allowedTypes: [],
@@ -84,6 +85,7 @@ class ListViewNode extends SinglePlaceholderNode
8485
shrinkWrap: false,
8586
keyboardDismissBehavior: keyboardDismissBehavior,
8687
useFlutterListView: true,
88+
shouldAlwaysScroll: shouldAlwaysScroll,
8789
);
8890
}
8991

lib/src/api/nodes/list_view_node.g.dart

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/nodes/page_view_node.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,11 @@ class PageViewNode extends SinglePlaceholderNode
5252
// [ScrollableMixin] properties.
5353
AxisC scrollDirection = AxisC.vertical,
5454
bool reverse = false,
55-
ScrollPhysicsC physics = ScrollPhysicsC.alwaysScrollableScrollPhysics,
55+
ScrollPhysicsC physics = ScrollPhysicsC.platformDependent,
5656
bool primary = false,
5757
ScrollViewKeyboardDismissBehaviorC keyboardDismissBehavior =
5858
ScrollViewKeyboardDismissBehaviorC.manual,
59+
bool shouldAlwaysScroll = true,
5960
}) : super(
6061
children: [],
6162
allowedTypes: [],
@@ -73,6 +74,7 @@ class PageViewNode extends SinglePlaceholderNode
7374
shrinkWrap: false,
7475
keyboardDismissBehavior: keyboardDismissBehavior,
7576
useFlutterListView: true,
77+
shouldAlwaysScroll: shouldAlwaysScroll,
7678
);
7779
}
7880

lib/src/api/nodes/page_view_node.g.dart

Lines changed: 10 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/api/nodes/row_column_node.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ class RowColumnNode extends ParentNode with RowColumnMixin, ScrollableMixin {
6868
// [ScrollableMixin] properties.
6969
bool isScrollable = false,
7070
bool reverse = false,
71-
ScrollPhysicsC physics = ScrollPhysicsC.alwaysScrollableScrollPhysics,
71+
ScrollPhysicsC physics = ScrollPhysicsC.platformDependent,
7272
bool primary = true,
7373
bool shrinkWrap = false,
7474
ScrollViewKeyboardDismissBehaviorC keyboardDismissBehavior =
7575
ScrollViewKeyboardDismissBehaviorC.manual,
7676
bool useFlutterListView = false,
77+
bool shouldAlwaysScroll = true,
7778
}) {
7879
setRowColumnMixin(
7980
rowColumnType: rowColumnType,
@@ -90,6 +91,7 @@ class RowColumnNode extends ParentNode with RowColumnMixin, ScrollableMixin {
9091
shrinkWrap: shrinkWrap,
9192
keyboardDismissBehavior: keyboardDismissBehavior,
9293
useFlutterListView: useFlutterListView,
94+
shouldAlwaysScroll: shouldAlwaysScroll,
9395
);
9496
}
9597

0 commit comments

Comments
 (0)