Skip to content

Commit feec13a

Browse files
authored
Remove duplicated key in _IconButtonM3 (#105577)
1 parent e09c132 commit feec13a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,6 @@ class IconButton extends StatelessWidget {
497497
);
498498
}
499499
return _IconButtonM3(
500-
key: key,
501500
style: adjustedStyle,
502501
onPressed: onPressed,
503502
autofocus: autofocus,
@@ -577,7 +576,6 @@ class IconButton extends StatelessWidget {
577576

578577
class _IconButtonM3 extends ButtonStyleButton {
579578
const _IconButtonM3({
580-
super.key,
581579
required super.onPressed,
582580
super.style,
583581
super.focusNode,

packages/flutter/test/material/icon_button_test.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ void main() {
2828
mockOnPressedFunction = MockOnPressedFunction();
2929
});
3030

31+
testWidgets('test icon is findable by key', (WidgetTester tester) async {
32+
const ValueKey<String> key = ValueKey<String>('icon-button');
33+
await tester.pumpWidget(
34+
wrap(
35+
useMaterial3: true,
36+
child: IconButton(
37+
key: key,
38+
onPressed: () {},
39+
icon: const Icon(Icons.link),
40+
),
41+
),
42+
);
43+
44+
expect(find.byKey(key), findsOneWidget);
45+
});
46+
3147
testWidgets('test default icon buttons are sized up to 48', (WidgetTester tester) async {
3248
final bool material3 = theme.useMaterial3;
3349
await tester.pumpWidget(

0 commit comments

Comments
 (0)