Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/guides/markdown-authoring.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Use these properties on blocks. Sections support `flex` and `align`;
`scrollable` applies to child blocks and widgets.

- `flex` – Relative size (default: `1`). A column with `flex: 2` takes twice the space of `flex: 1`
- `align` – Content alignment such as `topLeft`, `center`, and `bottomRight`
- `align` – Content alignment such as `topLeft`, `center`, and `bottomRight` (default: `centerLeft`)
- `scrollable` – Enable scrolling for overflow content (default: `false`)

For complete value definitions, see the [Markdown syntax reference](../reference/markdown-syntax).
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/block-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Content and widget blocks support these properties. Sections support `align`
and `flex`, but scrolling is configured on child blocks or widgets.

### `align`
**Type:** String | **Default:** `center`
**Type:** String | **Default:** `centerLeft`

Controls content alignment:
- `topLeft`, `topCenter`, `topRight`
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/markdown-syntax.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Built-in widgets (`image`, `dartpad`, `qrcode`) use the same widget syntax as `@
### `align`

- Type: string
- Default: `center`
- Default: `centerLeft`
- Values: `topLeft`, `topCenter`, `topRight`, `centerLeft`, `center`, `centerRight`, `bottomLeft`, `bottomCenter`, `bottomRight`

### `scrollable`
Expand Down
6 changes: 4 additions & 2 deletions packages/superdeck/lib/src/rendering/blocks/block_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ class _BlockContainerState extends State<_BlockContainer> {
child: content,
);

// Apply alignment
// Apply alignment. Blocks default to centerLeft so prose and embedded
// widgets align with left-to-right reading flow; set `align: center` to
// restore centered placement explicitly.
content = Align(
alignment: widget.block.align?.toAlignment ?? Alignment.center,
alignment: widget.block.align?.toAlignment ?? Alignment.centerLeft,
child: content,
);

Expand Down
36 changes: 36 additions & 0 deletions packages/superdeck/test/src/behavior/alignment_behavior_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,42 @@ void main() {
});
});

group('default alignment', () {
testWidgets('ContentBlock without explicit align defaults to centerLeft', (
tester,
) async {
final slide = Slide(
key: 'block-default-align',
sections: [
SectionBlock([ContentBlock('Hello')]),
],
);
await SlideTestHarness.pumpSlide(tester, slide);

final alignWidget = tester.widget<Align>(find.byType(Align).first);
expect(alignWidget.alignment, Alignment.centerLeft);
});

testWidgets('WidgetBlock without explicit align defaults to centerLeft', (
tester,
) async {
final slide = Slide(
key: 'widget-default-align',
sections: [
SectionBlock([WidgetBlock(name: 'plain')]),
],
);
await SlideTestHarness.pumpSlide(
tester,
slide,
widgets: {'plain': (_) => const SizedBox.shrink()},
);

final alignWidget = tester.widget<Align>(find.byType(Align).first);
expect(alignWidget.alignment, Alignment.centerLeft);
});
});

group('alignment in sections', () {
testWidgets('different alignments per section', (tester) async {
final slide = Slide(
Expand Down
Loading