Skip to content

Conversation

@OwenMcDonnell
Copy link
Contributor

@OwenMcDonnell OwenMcDonnell commented Nov 21, 2025

Description

SearchBar, Slider and Row example tests and images.

Add tap_at method to flet Tester class.

Summary by Sourcery

Add new test infrastructure and documentation imagery for Row, Slider, and SearchBar controls while extending tester capabilities for coordinate-based taps.

New Features:

  • Introduce a tap_at helper on the Python tester API and underlying Flutter tester service to simulate taps at specific screen offsets.
  • Add integration tests and golden image generation for Row and SearchBar examples, including animated spacing and wrapping scenarios.

Enhancements:

  • Update Row, Slider, and SearchBar documentation to reference new golden images and include simple inline code examples.
  • Adjust example scripts for Row and SearchBar to be directly runnable via main guards and align type hints with returned control lists.

Documentation:

  • Refresh Row, Slider, and SearchBar control docs to use centralized golden test images, updated captions, and resized imagery for clarity.

Tests:

  • Create new integration tests for core Row and material SearchBar examples, exercising layout behaviors and generating screenshots and GIFs for documentation.
  • Update Slider integration tests to use coordinate-based taps for event handling screenshots.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Nov 21, 2025

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 65a4a3c
Status: ✅  Deploy successful!
Preview URL: https://7e8c401b.flet-docs.pages.dev
Branch Preview URL: https://owen-control-docs-p5.flet-docs.pages.dev

View logs

"tap", {"finder_id": finder.id, "finder_index": finder.index}
)

async def tap_at(self, x_offset: int, y_offset: int):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have ft.Offset type which can be passed to method args "as is".

```python
ft.Row(
scroll=ft.ScrollMode.AUTO,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think scroll prop can be removed from this example, for brevity :)

var offsetObj = args["offset"];
var offsetX = offsetObj["x"].toDouble();
var offsetY = offsetObj["y"].toDouble();
var offset = Offset(offsetX, offsetY);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use parseOffset() function to parse received Offset object.

var offsetX = offsetObj["x"].toDouble();
var offsetY = offsetObj["y"].toDouble();
var offset = Offset(offsetX, offsetY);
debugPrint(offset.toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this debug statement.

Comment on lines 85 to 88
var offsetX = offsetObj["x"].toDouble();
var offsetY = offsetObj["y"].toDouble();
var offset = Offset(offsetX, offsetY);
debugPrint(offset.toString());
var offset = parseOffset(offsetObj);
if (offset == null) {
throw Exception("Offset not found: $offsetObj, $offset");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd do just:

var offset = parseOffset(args["offset"]);
if (offset == null) {
  throw Exception("Offset is required.");
}

Comment on lines 125 to 128
Args:
x_offset: x value of offset from top right.
y_offset: y value of offset from top right.
"""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update docstring, since we now have only one prop.

Comment on lines 22 to 35
ft.Row(
controls=[
ft.Card(
shape=ft.ContinuousRectangleBorder(radius=10),
content=ft.Container(
padding=5,
border_radius=ft.BorderRadius.all(5),
bgcolor=ft.Colors.AMBER_100,
content=ft.Text(f"Control {i}"),
),
)
for i in range(1, 6)
],
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ft.Row(
controls=[
ft.Card(
shape=ft.ContinuousRectangleBorder(radius=10),
content=ft.Container(
padding=5,
border_radius=ft.BorderRadius.all(5),
bgcolor=ft.Colors.AMBER_100,
content=ft.Text(f"Control {i}"),
),
)
for i in range(1, 6)
],
),
ft.Row(
controls=[
ft.Card(
shape=ft.ContinuousRectangleBorder(radius=10),
content=ft.Container(
padding=5,
border_radius=ft.BorderRadius.all(5),
bgcolor=ft.Colors.AMBER_100,
content=ft.Text(f"Control {i}"),
),
)
for i in range(1, 6)
],
)

Comment on lines 84 to 89
var offsetObj = args["offset"];
var offset = parseOffset(offsetObj);
if (offset == null) {
throw Exception("Offset not found: $offsetObj, $offset");
}
await control.backend.tester!.tapAt(offset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var offsetObj = args["offset"];
var offset = parseOffset(offsetObj);
if (offset == null) {
throw Exception("Offset not found: $offsetObj, $offset");
}
await control.backend.tester!.tapAt(offset);
var offset = parseOffset(args["offset"]);
if (offset != null) {
await control.backend.tester!.tapAt(offset);
}

Comment on lines +28 to +32
```python
ft.SearchBar(bar_hint_text="Search...")
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
```python
ft.SearchBar(bar_hint_text="Search...")
```
Example:
```python
ft.SearchBar(bar_hint_text="Search...")
```

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting this for every small code snippet at the top of a control's doc?
I think with small non-runnable example snippets it's unnecessary to label them as "examples"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants