Skip to content

Commit 1a74dd5

Browse files
committed
Version 4.0.3
* Updated so that in addition to `style`, the rest of the current context's DefaultTextStyle properties are provided to child text widgets (`textAlign`, `overflow`, `maxLines`, `textWidthBasis`, and `textHeightBehavior`).
1 parent 571a40c commit 1a74dd5

5 files changed

Lines changed: 27 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## [4.0.3] - March 24, 2025
4+
5+
* Updated so that in addition to `style`, the rest of the current context's DefaultTextStyle properties are provided to child text widgets (`textAlign`, `overflow`, `maxLines`, `textWidthBasis`, and `textHeightBehavior`).
6+
37
## [4.0.2] - March 10, 2025
48

59
* Fixed off-by-one error in the InlineSpan extension method `defaultSplitSpanAtIndex`.

lib/src/float_column.dart

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ class _FloatColumnElement extends RenderObjectElement
172172
final textOrWidget = floatColumnWidget._textAndWidgets[i];
173173
final widget = textOrWidget is Widget
174174
? textOrWidget
175-
: (textOrWidget as WrappableText).toWidget();
175+
: (textOrWidget as WrappableText)
176+
.toWidget(renderObject.defaultTextStyle);
176177
final newChild =
177178
inflateWidget(widget, IndexedSlot<Element?>(i, previousChild));
178179
children[i] = newChild;
@@ -186,7 +187,9 @@ class _FloatColumnElement extends RenderObjectElement
186187
super.update(newWidget);
187188
final floatColumnWidget = widget as FloatColumn;
188189
_children = updateChildren(
189-
_children, floatColumnWidget._textAndWidgets.toWidgets(),
190+
_children,
191+
floatColumnWidget._textAndWidgets
192+
.toWidgets(renderObject.defaultTextStyle),
190193
forgottenChildren: _forgottenChildren);
191194
_forgottenChildren.clear();
192195
}
@@ -406,8 +409,9 @@ Key? _firstNonUniqueKey(Iterable<Object> children) {
406409
}
407410

408411
extension on List<Object> {
409-
List<Widget> toWidgets() =>
410-
map((e) => e is Widget ? e : (e as WrappableText).toWidget()).toList();
412+
List<Widget> toWidgets(DefaultTextStyle defaultTextStyle) => map((e) =>
413+
e is Widget ? e : (e as WrappableText).toWidget(defaultTextStyle))
414+
.toList();
411415
}
412416

413417
/// Used as a placeholder in `List<Element>` objects when the actual

lib/src/render_float_column_ext.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ extension on RenderFloatColumn {
6565
// If the child is a RenderStack, set it back to the original
6666
// WrappableText widget.
6767
if (rc.child is RenderStack) {
68-
rc.updateCurrentChildWidget(el.toWidget());
68+
rc.updateCurrentChildWidget(el.toWidget(defaultTextStyle));
6969
}
7070

7171
_layoutWrappableText(el, rc, childConstraints, textDirection);
@@ -235,7 +235,7 @@ extension on RenderFloatColumn {
235235
} while (remaining.text.initialText().startsWith('\n'));
236236

237237
// Update the widget, and re-run the loop...
238-
rc.updateCurrentChildWidget(remaining.toWidget());
238+
rc.updateCurrentChildWidget(remaining.toWidget(defaultTextStyle));
239239
continue; //-------------------------------------------->
240240
}
241241

@@ -331,7 +331,7 @@ extension on RenderFloatColumn {
331331
text: parts.first, clearKey: textChunks.isNotEmpty);
332332

333333
// Update the current child's widget and re-layout it.
334-
rc.updateCurrentChildWidget(part1.toWidget());
334+
rc.updateCurrentChildWidget(part1.toWidget(defaultTextStyle));
335335
rc.child.layout(subConstraints, parentUsesSize: true);
336336

337337
// Does [part1] have any floated child widgets that needed to be
@@ -371,7 +371,7 @@ extension on RenderFloatColumn {
371371
maxLines: remainingLines,
372372
clearKey: textChunks.isNotEmpty);
373373

374-
rc.updateCurrentChildWidget(remaining.toWidget());
374+
rc.updateCurrentChildWidget(remaining.toWidget(defaultTextStyle));
375375

376376
// Re-run the loop...
377377
continue; //------------------------------------>
@@ -398,7 +398,7 @@ extension on RenderFloatColumn {
398398
));
399399

400400
rc.updateCurrentChildWidget(
401-
textChunks.toWidget(childConstraints.maxWidth));
401+
textChunks.toWidget(childConstraints.maxWidth, defaultTextStyle));
402402
rc.child.layout(childConstraints, parentUsesSize: true);
403403

404404
final top = textChunks.first.rect.top;
@@ -593,7 +593,7 @@ class _TextChunk {
593593
}
594594

595595
extension on List<_TextChunk> {
596-
Widget toWidget(double width) {
596+
Widget toWidget(double width, DefaultTextStyle defaultTextStyle) {
597597
// dmPrint('widgets:');
598598
// for (final t in this) {
599599
// dmPrint('object: ${t.x}, ${t.width}, ${t.text.toWidget()}');
@@ -611,7 +611,7 @@ extension on List<_TextChunk> {
611611
top: t.rect.top - top,
612612
child: SizedBox(
613613
width: t.rect.width,
614-
child: t.text.toWidget(),
614+
child: t.text.toWidget(defaultTextStyle),
615615
),
616616
),
617617
],

lib/src/wrappable_text.dart

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,17 +245,19 @@ class WrappableText {
245245
margin,
246246
padding);
247247

248-
Widget toWidget() => Text.rich(
248+
Widget toWidget(DefaultTextStyle defaultTextStyle) => Text.rich(
249249
text,
250250
key: key,
251-
textAlign: textAlign ?? TextAlign.start,
251+
textAlign: textAlign ?? defaultTextStyle.textAlign ?? TextAlign.start,
252252
textDirection: textDirection,
253-
overflow: overflow ?? TextOverflow.clip,
253+
overflow: overflow ?? defaultTextStyle.overflow,
254254
textScaler: textScaler,
255-
maxLines: maxLines,
255+
maxLines: maxLines ?? defaultTextStyle.maxLines,
256256
locale: locale,
257257
strutStyle: strutStyle,
258-
textHeightBehavior: textHeightBehavior,
258+
textWidthBasis: defaultTextStyle.textWidthBasis,
259+
textHeightBehavior:
260+
textHeightBehavior ?? defaultTextStyle.textHeightBehavior,
259261
);
260262
}
261263

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: float_column
22
description: Flutter FloatColumn widget for building a vertical column of widgets and text where the text wraps around floated widgets, similar to how CSS float works.
3-
version: 4.0.2
3+
version: 4.0.3
44
repository: https://github.com/ronjb/float_column
55

66
environment:

0 commit comments

Comments
 (0)