Skip to content

Commit 884c1be

Browse files
committed
Mirror PageView allowImplicitScrolling and Text textScaleFactor
Document in the README which Flutter parameters are represented elsewhere or cannot be JSON. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A67XoQYsLVvoMtiKcXXUxY
1 parent d9bbca2 commit 884c1be

7 files changed

Lines changed: 60 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
- `MaterialLoadingIndicatorProperties.strokeAlign`, `trackGap`
4444
- `ExpansionTileProperties.showTrailingIcon`, `shape`, `collapsedShape`,
4545
`cornerRadius`
46-
- `TextMixin.softWrap`
46+
- `TextMixin.softWrap`, `textScaleFactor`
47+
- `PageViewProperties.allowImplicitScrolling`
4748
- Document the Flutter replacements for deprecated `cacheExtent`
4849
(`scrollCacheExtent`) and `Radio.groupValue` (`RadioGroup`).
4950
- New nodes use Material 3 defaults: switches use Material 3, buttons are

‎README.md‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,23 @@ or image texture.
116116
opacity (`opacity`), among others. Depending on the type of paint, it might have properties like color (`color`),
117117
gradient transform (`gradientTransform`), gradient stops (`gradientStops`), or image transform (`imageTransform`).
118118

119+
### Flutter parity
120+
121+
Models track the Flutter release this version supports (3.47). A Flutter
122+
parameter is left out when it cannot be data or is already expressed
123+
elsewhere:
124+
125+
| Flutter parameter | Represented by |
126+
|---|---|
127+
| Size and padding parameters such as `ButtonStyle.minimumSize`/`fixedSize`, `InputDecoration.contentPadding` and `TabBar.padding` | The node's own box and `padding` |
128+
| `ScrollView.clipBehavior` and similar clip parameters | `ClipMixin.clipsContent` |
129+
| Callbacks and widgets, such as `itemExtentBuilder` and `prototypeItem` | Not representable as JSON; use `itemExtent` |
130+
| `Icon.fill`/`weight`/`grade`/`opticalSize` | Pending Material Symbols support in the SDK, which renders icons as SVGs |
131+
132+
Defaults follow Material 3. Where a default changed from an earlier
133+
version, the old value still applies to JSON that omits the key (see
134+
`JsonLegacyDefault`), so saved designs keep their look.
135+
119136
## Contributing
120137

121138
Contributions are welcome! Please open an issue to start a discussion.

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ class PageViewProperties extends CustomProperties with FieldsHolder {
137137
/// The fraction of the viewport that each page should occupy.
138138
double viewportFraction;
139139

140+
/// Whether to lay out the pages next to the visible one, so accessibility
141+
/// focus can move to them. Mirrors `PageView.allowImplicitScrolling`.
142+
bool allowImplicitScrolling;
143+
140144
/// Creates a [PageViewProperties].
141145
PageViewProperties({
142146
this.itemCount,
@@ -145,6 +149,7 @@ class PageViewProperties extends CustomProperties with FieldsHolder {
145149
this.keepPage = true,
146150
this.initialPage = 0,
147151
this.viewportFraction = 1,
152+
this.allowImplicitScrolling = false,
148153
});
149154

150155
/// Creates a [PageViewProperties] from a JSON object.
@@ -155,6 +160,7 @@ class PageViewProperties extends CustomProperties with FieldsHolder {
155160
bool? keepPage,
156161
int? initialPage,
157162
double? viewportFraction,
163+
bool? allowImplicitScrolling,
158164
}) {
159165
return PageViewProperties(
160166
itemCount: itemCount ?? this.itemCount,
@@ -163,6 +169,8 @@ class PageViewProperties extends CustomProperties with FieldsHolder {
163169
keepPage: keepPage ?? this.keepPage,
164170
initialPage: initialPage ?? this.initialPage,
165171
viewportFraction: viewportFraction ?? this.viewportFraction,
172+
allowImplicitScrolling:
173+
allowImplicitScrolling ?? this.allowImplicitScrolling,
166174
);
167175
}
168176

@@ -195,6 +203,12 @@ class PageViewProperties extends CustomProperties with FieldsHolder {
195203
(value) => viewportFraction = value,
196204
requiresLayout: true,
197205
),
206+
'allowImplicitScrolling': BoolFieldAccess(
207+
'Allow Implicit Scrolling',
208+
'Whether to lay out the pages next to the visible one.',
209+
() => allowImplicitScrolling,
210+
(value) => allowImplicitScrolling = value,
211+
),
198212
};
199213

200214
@override
@@ -205,6 +219,7 @@ class PageViewProperties extends CustomProperties with FieldsHolder {
205219
keepPage,
206220
initialPage,
207221
viewportFraction,
222+
allowImplicitScrolling,
208223
];
209224

210225
@override

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

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

‎lib/src/api/nodes/text_node.dart‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ class TextNode extends SceneNode with BlendMixin, TextMixin, FontMixin {
112112
int? maxLines,
113113
TextOverflowC overflow = TextOverflowC.clip,
114114
bool softWrap = true,
115+
double? textScaleFactor,
115116
// [BlendMixin] properties.
116117
double opacity = 1.0,
117118
bool isMask = false,
@@ -131,6 +132,7 @@ class TextNode extends SceneNode with BlendMixin, TextMixin, FontMixin {
131132
maxLines: maxLines,
132133
overflow: overflow,
133134
softWrap: softWrap,
135+
textScaleFactor: textScaleFactor,
134136
);
135137

136138
setBlendMixin(
@@ -196,6 +198,10 @@ mixin TextMixin {
196198
/// as if there were unlimited horizontal space. Mirrors `Text.softWrap`.
197199
late bool softWrap;
198200

201+
/// Factor by which to scale the font size, on top of the platform's text
202+
/// scaling. Mirrors `Text.textScaler` as `TextScaler.linear`.
203+
late double? textScaleFactor;
204+
199205
/// Set text properties.
200206
void setTextMixin({
201207
required String characters,
@@ -207,6 +213,7 @@ mixin TextMixin {
207213
required TextOverflowC overflow,
208214
int? maxLines,
209215
bool softWrap = true,
216+
double? textScaleFactor,
210217
}) {
211218
this.characters = characters;
212219
this.textMixedProps = textMixedProps;
@@ -217,6 +224,7 @@ mixin TextMixin {
217224
this.maxLines = maxLines;
218225
this.overflow = overflow;
219226
this.softWrap = softWrap;
227+
this.textScaleFactor = textScaleFactor;
220228
}
221229
}
222230

‎lib/src/api/nodes/text_node.g.dart‎

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎test/properties_test.dart‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,17 @@ void main() {
248248
expect(TextNode.fromJson(text(false).toJson()).softWrap, isFalse);
249249
});
250250

251+
test('PageViewProperties.allowImplicitScrolling', () {
252+
expect(
253+
PageViewProperties().toJson(),
254+
isNot(contains('allowImplicitScrolling')),
255+
);
256+
final copy = PageViewProperties.fromJson(
257+
PageViewProperties(allowImplicitScrolling: true).toJson(),
258+
);
259+
expect(copy.allowImplicitScrolling, isTrue);
260+
});
261+
251262
test('4.4.0 nodes keep their Material 2 look', () {
252263
final fab = FloatingActionButtonProperties.fromJson({});
253264
expect(fab.shape, CShapeBorder.circle);

0 commit comments

Comments
 (0)