Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

### Bug fixes

* Fix `Dropdown.expanded_insets` having no effect when `expand` is set ([#6895](https://github.com/flet-dev/flet/issues/6895), [#6896](https://github.com/flet-dev/flet/pull/6896)) by @xsalaices.
* Fix `Tabs` ignoring a new `selected_index` set together with a new `length` - e.g. inserting a tab before the selected one and moving `selected_index` to follow it selected the inserted tab instead ([#6901](https://github.com/flet-dev/flet/pull/6901)) by @FeodorFitsner.
* Fix controls losing their state (a `TextField` its focus and cursor, a list its scroll position) when a sibling before them in a `Column`, `Row` or other multi-child control became visible or hidden: children were matched by position, so the shift rebuilt them. Children are now matched by control id ([#6901](https://github.com/flet-dev/flet/pull/6901)) by @FeodorFitsner.
* Fix `FilePicker.upload()` with several files uploading the wrong file to each URL: after the first upload, each file's `id` pointed at the next picked file, so a file's bytes went to another file's URL and the last file never uploaded (its caller waited forever). Picked files now keep their `id` across `upload()` calls, and files that can't be found report an upload error ([#6901](https://github.com/flet-dev/flet/pull/6901)) by @FeodorFitsner.
Expand Down
4 changes: 3 additions & 1 deletion packages/flet/lib/src/controls/dropdown.dart
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,9 @@ class _DropdownControlState extends State<DropdownControl> {
_focusNode.canRequestFocus = editable;

int expand = widget.control.getExpand("expand", 0)!;
EdgeInsets? expandedInsets = expand > 0 ? EdgeInsets.zero : null;
EdgeInsets? expandedInsets = expand > 0
? widget.control.getPadding("expanded_insets", EdgeInsets.zero)
: null;

Widget dropDown = DropdownMenu<String>(
key: dropdownMenuKey,
Expand Down
91 changes: 91 additions & 0 deletions packages/flet/test/widgets/dropdown_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import 'package:flet/src/controls/dropdown.dart';
import 'package:flet/src/flet_backend.dart';
import 'package:flet/src/models/control.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

class _TestBackend extends FletBackend {
_TestBackend()
: super(
pageUri: Uri.parse('http://localhost'),
assetsDir: '',
extensions: [],
multiView: false);
}

void main() {
testWidgets('Dropdown.expanded_insets is applied when expand is set',
(tester) async {
final backend = _TestBackend();
final control = Control(
id: 1,
type: 'Dropdown',
properties: {
'expand': 1,
'expanded_insets': {
'left': 40.0,
'top': 0.0,
'right': 40.0,
'bottom': 0.0
},
'options': [],
},
backend: backend);

await tester.pumpWidget(
MaterialApp(home: Scaffold(body: DropdownControl(control: control))));

expect(tester.takeException(), isNull);
final menu =
tester.widget<DropdownMenu<String>>(find.byType(DropdownMenu<String>));
expect(menu.expandedInsets, const EdgeInsets.fromLTRB(40, 0, 40, 0));
});

testWidgets(
'Dropdown falls back to zero insets when expand is set without expanded_insets',
(tester) async {
final backend = _TestBackend();
final control = Control(
id: 1,
type: 'Dropdown',
properties: {
'expand': 1,
'options': [],
},
backend: backend);

await tester.pumpWidget(
MaterialApp(home: Scaffold(body: DropdownControl(control: control))));

expect(tester.takeException(), isNull);
final menu =
tester.widget<DropdownMenu<String>>(find.byType(DropdownMenu<String>));
expect(menu.expandedInsets, EdgeInsets.zero);
});

testWidgets('Dropdown has null expandedInsets when not expanded',
(tester) async {
final backend = _TestBackend();
final control = Control(
id: 1,
type: 'Dropdown',
properties: {
'expanded_insets': {
'left': 40.0,
'top': 0.0,
'right': 40.0,
'bottom': 0.0
},
'options': [],
},
backend: backend);

await tester.pumpWidget(
MaterialApp(home: Scaffold(body: DropdownControl(control: control))));

expect(tester.takeException(), isNull);
final menu =
tester.widget<DropdownMenu<String>>(find.byType(DropdownMenu<String>));
expect(menu.expandedInsets, isNull);
});
}