Skip to content

Commit e4a0d79

Browse files
polina-cgilnobrega
authored andcommitted
Get rid of _NullElement. (flutter#146741)
Fixes flutter#145602
1 parent 03a234e commit e4a0d79

File tree

2 files changed

+5
-24
lines changed

2 files changed

+5
-24
lines changed

packages/flutter/lib/src/cupertino/text_selection_toolbar.dart

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -887,13 +887,12 @@ class _CupertinoTextSelectionToolbarItemsElement extends RenderObjectElement {
887887
_mountChild(toolbarItems.nextButton, _CupertinoTextSelectionToolbarItemsSlot.nextButton);
888888

889889
// Mount list children.
890-
_children = List<Element>.filled(toolbarItems.children.length, _NullElement.instance);
891890
Element? previousChild;
892-
for (int i = 0; i < _children.length; i += 1) {
893-
final Element newChild = inflateWidget(toolbarItems.children[i], IndexedSlot<Element?>(i, previousChild));
894-
_children[i] = newChild;
895-
previousChild = newChild;
896-
}
891+
_children = List<Element>.generate(toolbarItems.children.length, (int i) {
892+
final Element result = inflateWidget(toolbarItems.children[i], IndexedSlot<Element?>(i, previousChild));
893+
previousChild = result;
894+
return result;
895+
}, growable: false);
897896
}
898897

899898
@override
@@ -1273,19 +1272,3 @@ enum _CupertinoTextSelectionToolbarItemsSlot {
12731272
backButton,
12741273
nextButton,
12751274
}
1276-
1277-
class _NullElement extends Element {
1278-
_NullElement() : super(const _NullWidget());
1279-
1280-
static _NullElement instance = _NullElement();
1281-
1282-
@override
1283-
bool get debugDoingBuild => throw UnimplementedError();
1284-
}
1285-
1286-
class _NullWidget extends Widget {
1287-
const _NullWidget();
1288-
1289-
@override
1290-
Element createElement() => throw UnimplementedError();
1291-
}

packages/flutter/test/flutter_test_config.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ Future<void> testExecutable(FutureOr<void> Function() testMain) {
5252
classes: <String>[
5353
// TODO(polina-c): CurvedAnimation is leaking, https://github.com/flutter/flutter/issues/145600 [leaks-to-clean]
5454
'CurvedAnimation',
55-
// TODO(polina-c): _NullElement is leaking, https://github.com/flutter/flutter/issues/145602 [leaks-to-clean]
56-
'_NullElement',
5755
],
5856
);
5957
}

0 commit comments

Comments
 (0)