Skip to content

Commit 3c01a4a

Browse files
authored
text_change event for Dropdown and more integration tests (#5591)
* Add size constraints to SearchBar and improve docs Introduces `bar_size_constraints` to the SearchBar control and theme, allowing optional size constraints. Also updates and expands documentation for SearchBar properties and SearchBarTheme overrides for better clarity and developer guidance. * Add integration test for SearchBar on macOS Introduces a new integration test for the SearchBar control, including golden images for its basic and opened states on macOS. The test verifies SearchBar rendering and interaction, ensuring correct UI behavior. * Add themed SearchBar integration test for macOS Introduces a new test for SearchBar theming in macOS, including screenshots for normal, hovered, and opened states. Verifies custom theme properties and interaction behaviors. * Add padding and shrink_wrap options to SearchBar Introduces viewPadding, viewBarPadding, and shrinkWrap properties to SearchBar and SearchViewTheme for enhanced customization. Updates integration tests and documentation to reflect new options for controlling search view layout and appearance. * Remove unused ListTile click handlers in SearchBar tests Eliminated the handle_tile_click function and its usage in SearchBar integration tests, as the click handler is no longer needed. Also added detailed docstrings to NavigationDrawerTheme fields for improved documentation. * Refactor navigation drawer tests and add theme test Renamed screenshot files and updated test names for clarity. Added a new test for navigation drawer theme and its corresponding golden image. Refactored fixture usage and screenshot assertions to improve test structure and maintainability. * Add label_padding to NavigationBar and theme docs Introduces the label_padding property to NavigationBar and NavigationBarTheme for customizing label padding. Improves and clarifies documentation for NavigationBar, TabBar, SearchBarTheme, SearchViewTheme, and NavigationDrawerTheme properties, including corrections to property references and expanded descriptions. * Add themed NavigationBar integration tests for macOS Renamed navigation_bar.png to basic.png and added new golden images for themed NavigationBar states. Updated test_navigation_bar.py to include separate tests for basic and themed NavigationBar, verifying appearance under different theme settings and user interactions. * Enhance SegmentedButton icon support and tests Updated SegmentedButton to support both IconData and Control for selected_icon. Improved integration tests for segmented button, added golden images for macOS, and documented SegmentedButtonTheme options. Also clarified NavigationBarTheme test comments. * Add text change event to Dropdown control Introduces a text change event handler for the Dropdown control in both Dart and Python implementations. The Dart Dropdown now uses a TextEditingController to track input changes, updating properties and triggering the new 'text_change' event. The Python Dropdown class adds an 'on_text_change' callback for handling text input changes. * Update dropdown.dart * Refactor icon test and improve IconTheme docs Renamed and updated the icon test to use function-scoped async fixtures and improved test isolation. Enhanced documentation for IconTheme properties with detailed docstrings. Removed and replaced golden image files for icon and segmented button tests. * Add icon theme integration test and fix BoxShadow type Introduces a new integration test for icon theme settings, including screenshot validation. Updates IconTheme's 'shadows' attribute type from list[BoxShadow] to BoxShadowValue for consistency with usage. * Improve theme class docstrings and DataTableTheme docs Refined docstrings for NavigationDrawerTheme, NavigationBarTheme, SegmentedButtonTheme, and IconTheme to clarify scope as app-wide. Expanded DataTableTheme docstring and added detailed documentation for each property, specifying their purpose and corresponding DataTable attributes.
1 parent 79e284b commit 3c01a4a

33 files changed

Lines changed: 900 additions & 60 deletions

client/pubspec.lock

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,10 @@ packages:
245245
dependency: transitive
246246
description:
247247
name: file_picker
248-
sha256: ef7d2a085c1b1d69d17b6842d0734aad90156de08df6bd3c12496d0bd6ddf8e2
248+
sha256: e7e16c9d15c36330b94ca0e2ad8cb61f93cd5282d0158c09805aed13b5452f22
249249
url: "https://pub.dev"
250250
source: hosted
251-
version: "10.3.1"
251+
version: "10.3.2"
252252
fixnum:
253253
dependency: transitive
254254
description:
@@ -277,7 +277,7 @@ packages:
277277
description:
278278
path: "src/flutter/flet_ads"
279279
ref: main
280-
resolved-ref: e847a431388733d6bcd81748c617a3b962c5efa9
280+
resolved-ref: aa05773138be06e69353e2a223bd23c51b36dd3f
281281
url: "https://github.com/flet-dev/flet-ads.git"
282282
source: git
283283
version: "0.2.0"
@@ -286,7 +286,7 @@ packages:
286286
description:
287287
path: "src/flutter/flet_audio"
288288
ref: main
289-
resolved-ref: "5611fa1ef47c2faeeb6317671932cfd3ee2888c3"
289+
resolved-ref: "06fb901f133fab54e603f8039bc9a1d707d19068"
290290
url: "https://github.com/flet-dev/flet-audio.git"
291291
source: git
292292
version: "0.2.0"
@@ -295,7 +295,7 @@ packages:
295295
description:
296296
path: "src/flutter/flet_audio_recorder"
297297
ref: main
298-
resolved-ref: "10c9108060410c3c4e2435311c8e4ee70daf24bf"
298+
resolved-ref: "62a1934a34514e92617f4e090b53828474f5969e"
299299
url: "https://github.com/flet-dev/flet-audio-recorder.git"
300300
source: git
301301
version: "0.2.0"
@@ -313,7 +313,7 @@ packages:
313313
description:
314314
path: "src/flutter/flet_datatable2"
315315
ref: main
316-
resolved-ref: ebd7adc75486b276df382ae6401037c45a6df2a3
316+
resolved-ref: bf6af9c7a9c1962c36512ff5ab48eec9f14ef81a
317317
url: "https://github.com/flet-dev/flet-datatable2.git"
318318
source: git
319319
version: "0.1.0"
@@ -322,7 +322,7 @@ packages:
322322
description:
323323
path: "src/flutter/flet_flashlight"
324324
ref: main
325-
resolved-ref: "88fb80a6b4032956282a4be9c60f3c25f3cfccb5"
325+
resolved-ref: def30504c3ed6786dc2a1fdb4f18b226a284a7d2
326326
url: "https://github.com/flet-dev/flet-flashlight.git"
327327
source: git
328328
version: "0.2.0"
@@ -331,7 +331,7 @@ packages:
331331
description:
332332
path: "src/flutter/flet_geolocator"
333333
ref: main
334-
resolved-ref: "94ed74df1a8b791d0afaccc2f9caac3456698f78"
334+
resolved-ref: "25efd0a9d15f23bf284912814a131388f8de9ec4"
335335
url: "https://github.com/flet-dev/flet-geolocator.git"
336336
source: git
337337
version: "0.25.2"
@@ -340,7 +340,7 @@ packages:
340340
description:
341341
path: "src/flutter/flet_lottie"
342342
ref: main
343-
resolved-ref: "86eaa0b59f3cc54f9b2fb57abce9c0d22de253ca"
343+
resolved-ref: "5187fcf6bcb37f4bfa59cad127f6444d40cdb48c"
344344
url: "https://github.com/flet-dev/flet-lottie.git"
345345
source: git
346346
version: "0.2.0"
@@ -349,7 +349,7 @@ packages:
349349
description:
350350
path: "src/flutter/flet_map"
351351
ref: main
352-
resolved-ref: "8507cda6616f555974fbdcd3df05c3f2b02c043f"
352+
resolved-ref: d79ebf24ebad208a543b73a7f7511cd4da1d7ea9
353353
url: "https://github.com/flet-dev/flet-map.git"
354354
source: git
355355
version: "0.2.0"
@@ -358,7 +358,7 @@ packages:
358358
description:
359359
path: "src/flutter/flet_permission_handler"
360360
ref: main
361-
resolved-ref: "2a56423dd77d220a0067f4097f9e25659b2f9b36"
361+
resolved-ref: dbd04f183b8452a5247f2807007cc40a2381a172
362362
url: "https://github.com/flet-dev/flet-permission-handler.git"
363363
source: git
364364
version: "0.2.0"
@@ -367,7 +367,7 @@ packages:
367367
description:
368368
path: "src/flutter/flet_rive"
369369
ref: main
370-
resolved-ref: "67256e81ec7c906ae03790b0c180c9be018ed7a4"
370+
resolved-ref: "6d78b068940afa5126fc38374ea326e710d43862"
371371
url: "https://github.com/flet-dev/flet-rive.git"
372372
source: git
373373
version: "0.2.0"
@@ -376,7 +376,7 @@ packages:
376376
description:
377377
path: "src/flutter/flet_video"
378378
ref: main
379-
resolved-ref: a086b89d74f96e052a450d6c2a50c812a035ce45
379+
resolved-ref: abeea4e9a3a2864299743726b26d5a245a4389d6
380380
url: "https://github.com/flet-dev/flet-video.git"
381381
source: git
382382
version: "0.2.0"
@@ -385,7 +385,7 @@ packages:
385385
description:
386386
path: "src/flutter/flet_webview"
387387
ref: main
388-
resolved-ref: "9e2b64171f81cbe72a8a61ee9ba9d2af69587837"
388+
resolved-ref: cb3d07bfb84ae1b51be25388ca04c03a9dafd7f3
389389
url: "https://github.com/flet-dev/flet-webview.git"
390390
source: git
391391
version: "0.2.0"
@@ -1028,18 +1028,18 @@ packages:
10281028
dependency: transitive
10291029
description:
10301030
name: record_android
1031-
sha256: "8b170e33d9866f9b51e01a767d7e1ecb97b9ecd629950bd87a47c79359ec57f8"
1031+
sha256: "8361a791c9a3fa5c065f0b8b5adb10f12531f8538c86b19474cf7b56ea80d426"
10321032
url: "https://pub.dev"
10331033
source: hosted
1034-
version: "1.4.0"
1034+
version: "1.4.1"
10351035
record_ios:
10361036
dependency: transitive
10371037
description:
10381038
name: record_ios
1039-
sha256: ad97d0a75933c44bcf5aff648e86e32fc05eb61f8fbef190f14968c8eaf86692
1039+
sha256: "13e241ed9cbc220534a40ae6b66222e21288db364d96dd66fb762ebd3cb77c71"
10401040
url: "https://pub.dev"
10411041
source: hosted
1042-
version: "1.1.0"
1042+
version: "1.1.2"
10431043
record_linux:
10441044
dependency: transitive
10451045
description:
@@ -1052,10 +1052,10 @@ packages:
10521052
dependency: transitive
10531053
description:
10541054
name: record_macos
1055-
sha256: f1399bca76a1634da109e5b0cba764ed8332a2b4da49c704c66d2c553405ed81
1055+
sha256: "2849068bb59072f300ad63ed146e543d66afaef8263edba4de4834fc7c8d4d35"
10561056
url: "https://pub.dev"
10571057
source: hosted
1058-
version: "1.1.0"
1058+
version: "1.1.1"
10591059
record_platform_interface:
10601060
dependency: transitive
10611061
description:
@@ -1076,10 +1076,10 @@ packages:
10761076
dependency: transitive
10771077
description:
10781078
name: record_windows
1079-
sha256: "85a22fc97f6d73ecd67c8ba5f2f472b74ef1d906f795b7970f771a0914167e99"
1079+
sha256: "223258060a1d25c62bae18282c16783f28581ec19401d17e56b5205b9f039d78"
10801080
url: "https://pub.dev"
10811081
source: hosted
1082-
version: "1.0.6"
1082+
version: "1.0.7"
10831083
rive:
10841084
dependency: transitive
10851085
description:

packages/flet/lib/src/controls/dropdown.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,27 @@ class DropdownControl extends StatefulWidget {
1515

1616
class _DropdownControlState extends State<DropdownControl> {
1717
late final FocusNode _focusNode;
18+
late final TextEditingController _controller;
1819

1920
@override
2021
void initState() {
2122
super.initState();
2223
_focusNode = FocusNode();
24+
25+
_controller =
26+
TextEditingController(text: widget.control.getString("value"));
2327
_focusNode.addListener(_onFocusChange);
2428
widget.control.addInvokeMethodListener(_invokeMethod);
29+
30+
_controller.addListener(_onTextChange);
31+
}
32+
33+
void _onTextChange() {
34+
debugPrint("Typed text: ${_controller.text}");
35+
if (_controller.text != widget.control.getString("value")) {
36+
widget.control.updateProperties({"value": _controller.text});
37+
widget.control.triggerEvent("text_change", _controller.text);
38+
}
2539
}
2640

2741
void _onFocusChange() {
@@ -33,6 +47,7 @@ class _DropdownControlState extends State<DropdownControl> {
3347
_focusNode.removeListener(_onFocusChange);
3448
_focusNode.dispose();
3549
widget.control.removeInvokeMethodListener(_invokeMethod);
50+
_controller.dispose();
3651
super.dispose();
3752
}
3853

@@ -182,6 +197,7 @@ class _DropdownControlState extends State<DropdownControl> {
182197
Widget dropDown = DropdownMenu<String>(
183198
enabled: !widget.control.disabled,
184199
focusNode: _focusNode,
200+
controller: _controller,
185201
initialSelection: value,
186202
enableFilter: widget.control.getBool("enable_filter", false)!,
187203
enableSearch: widget.control.getBool("enable_search", true)!,

packages/flet/lib/src/controls/search_bar.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ class _SearchBarControlState extends State<SearchBarControl> {
171171
headerTextStyle:
172172
widget.control.getTextStyle("view_header_text_style", theme),
173173
viewSide: widget.control.getBorderSide("view_side", theme),
174+
viewPadding: widget.control.getPadding("view_padding"),
175+
viewBarPadding: widget.control.getPadding("view_bar_padding"),
176+
shrinkWrap: widget.control.getBool("shrink_wrap"),
174177
isFullScreen: widget.control.getBool("full_screen", false),
175178
viewBackgroundColor: widget.control.getColor("view_bgcolor", context),
176179
dividerColor: widget.control.getColor("divider_color", context),
@@ -208,6 +211,8 @@ class _SearchBarControlState extends State<SearchBarControl> {
208211
shape:
209212
widget.control.getWidgetStateOutlinedBorder("bar_shape", theme),
210213
padding: widget.control.getWidgetStatePadding("bar_padding"),
214+
constraints:
215+
widget.control.getBoxConstraints("bar_size_constraints"),
211216
textStyle:
212217
widget.control.getWidgetStateTextStyle("bar_text_style", theme),
213218
hintStyle: widget.control

packages/flet/lib/src/controls/segmented_button.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class _SegmentedButtonControlState extends State<SegmentedButtonControl>
8484
selected: selected,
8585
showSelectedIcon: widget.control.getBool("show_selected_icon", true)!,
8686
style: style,
87-
selectedIcon: widget.control.buildWidget("selected_icon"),
87+
selectedIcon: widget.control.buildIconOrWidget("selected_icon"),
8888
onSelectionChanged: !widget.control.disabled
8989
? (newSelection) => onChange(newSelection)
9090
: null,
17.5 KB
Loading
Binary file not shown.
165 KB
Loading

sdk/python/packages/flet/integration_tests/controls/golden/macos/navigation_bar/navigation_bar.png renamed to sdk/python/packages/flet/integration_tests/controls/golden/macos/navigation_bar/basic.png

File renamed without changes.
9.6 KB
Loading
10.5 KB
Loading

0 commit comments

Comments
 (0)