Skip to content

Commit 042c036

Browse files
authored
Remove unnecessary variable _hasPrimaryFocus (#129066)
`_hasPrimaryFocus` variable and its related code is no longer needed after using `InkWell` for `DropdownButton` at flutter/flutter#95906
1 parent 32fde13 commit 042c036

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

packages/flutter/lib/src/material/dropdown.dart

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,6 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
12211221
Orientation? _lastOrientation;
12221222
FocusNode? _internalNode;
12231223
FocusNode? get focusNode => widget.focusNode ?? _internalNode;
1224-
bool _hasPrimaryFocus = false;
12251224
late Map<Type, Action<Intent>> _actionMap;
12261225

12271226
// Only used if needed to create _internalNode.
@@ -1244,14 +1243,12 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
12441243
onInvoke: (ButtonActivateIntent intent) => _handleTap(),
12451244
),
12461245
};
1247-
focusNode!.addListener(_handleFocusChanged);
12481246
}
12491247

12501248
@override
12511249
void dispose() {
12521250
WidgetsBinding.instance.removeObserver(this);
12531251
_removeDropdownRoute();
1254-
focusNode!.removeListener(_handleFocusChanged);
12551252
_internalNode?.dispose();
12561253
super.dispose();
12571254
}
@@ -1262,25 +1259,11 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
12621259
_lastOrientation = null;
12631260
}
12641261

1265-
void _handleFocusChanged() {
1266-
if (_hasPrimaryFocus != focusNode!.hasPrimaryFocus) {
1267-
setState(() {
1268-
_hasPrimaryFocus = focusNode!.hasPrimaryFocus;
1269-
});
1270-
}
1271-
}
1272-
1273-
12741262
@override
12751263
void didUpdateWidget(DropdownButton<T> oldWidget) {
12761264
super.didUpdateWidget(oldWidget);
1277-
if (widget.focusNode != oldWidget.focusNode) {
1278-
oldWidget.focusNode?.removeListener(_handleFocusChanged);
1279-
if (widget.focusNode == null) {
1280-
_internalNode ??= _createFocusNode();
1281-
}
1282-
_hasPrimaryFocus = focusNode!.hasPrimaryFocus;
1283-
focusNode!.addListener(_handleFocusChanged);
1265+
if (widget.focusNode == null) {
1266+
_internalNode ??= _createFocusNode();
12841267
}
12851268
_updateSelectedIndex();
12861269
}

0 commit comments

Comments
 (0)