Adds missing style
to PopupMenuButton
(#143392)
Adds missing `style` to `PopupMenuButton`. Fixes: #114709
This commit is contained in:
parent
bb8fc6e9a9
commit
311c0064d8
@ -7,6 +7,7 @@ import 'package:flutter/rendering.dart';
|
|||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
|
||||||
|
import 'button_style.dart';
|
||||||
import 'color_scheme.dart';
|
import 'color_scheme.dart';
|
||||||
import 'colors.dart';
|
import 'colors.dart';
|
||||||
import 'constants.dart';
|
import 'constants.dart';
|
||||||
@ -1149,6 +1150,7 @@ class PopupMenuButton<T> extends StatefulWidget {
|
|||||||
this.clipBehavior = Clip.none,
|
this.clipBehavior = Clip.none,
|
||||||
this.useRootNavigator = false,
|
this.useRootNavigator = false,
|
||||||
this.popUpAnimationStyle,
|
this.popUpAnimationStyle,
|
||||||
|
this.style,
|
||||||
}) : assert(
|
}) : assert(
|
||||||
!(child != null && icon != null),
|
!(child != null && icon != null),
|
||||||
'You can only pass [child] or [icon], not both.',
|
'You can only pass [child] or [icon], not both.',
|
||||||
@ -1343,6 +1345,15 @@ class PopupMenuButton<T> extends StatefulWidget {
|
|||||||
/// If this is null, then the default animation will be used.
|
/// If this is null, then the default animation will be used.
|
||||||
final AnimationStyle? popUpAnimationStyle;
|
final AnimationStyle? popUpAnimationStyle;
|
||||||
|
|
||||||
|
/// Customizes this icon button's appearance.
|
||||||
|
///
|
||||||
|
/// The [style] is only used for Material 3 [IconButton]s. If [ThemeData.useMaterial3]
|
||||||
|
/// is set to true, [style] is preferred for icon button customization, and any
|
||||||
|
/// parameters defined in [style] will override the same parameters in [IconButton].
|
||||||
|
///
|
||||||
|
/// Null by default.
|
||||||
|
final ButtonStyle? style;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
PopupMenuButtonState<T> createState() => PopupMenuButtonState<T>();
|
PopupMenuButtonState<T> createState() => PopupMenuButtonState<T>();
|
||||||
}
|
}
|
||||||
@ -1455,6 +1466,7 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
|
|||||||
tooltip: widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip,
|
tooltip: widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip,
|
||||||
onPressed: widget.enabled ? showButtonMenu : null,
|
onPressed: widget.enabled ? showButtonMenu : null,
|
||||||
enableFeedback: enableFeedback,
|
enableFeedback: enableFeedback,
|
||||||
|
style: widget.style,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4060,6 +4060,33 @@ void main() {
|
|||||||
expect(listViewportBounds.bottomRight.dy, lessThanOrEqualTo(windowSize.height));
|
expect(listViewportBounds.bottomRight.dy, lessThanOrEqualTo(windowSize.height));
|
||||||
expect(listViewportBounds, overlaps(buttonBounds));
|
expect(listViewportBounds, overlaps(buttonBounds));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('PopupMenuButton honors style', (WidgetTester tester) async {
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Scaffold(
|
||||||
|
body: PopupMenuButton<int>(
|
||||||
|
style: const ButtonStyle(
|
||||||
|
iconColor: MaterialStatePropertyAll<Color>(Colors.red),
|
||||||
|
),
|
||||||
|
itemBuilder: (BuildContext context) {
|
||||||
|
return <PopupMenuItem<int>>[
|
||||||
|
const PopupMenuItem<int>(
|
||||||
|
value: 1,
|
||||||
|
child: Text('One'),
|
||||||
|
),
|
||||||
|
];
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final RichText iconText = tester.firstWidget(find.descendant(
|
||||||
|
of: find.byType(PopupMenuButton<int>),
|
||||||
|
matching: find.byType(RichText),
|
||||||
|
));
|
||||||
|
expect(iconText.text.style?.color, Colors.red);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Matcher overlaps(Rect other) => OverlapsMatcher(other);
|
Matcher overlaps(Rect other) => OverlapsMatcher(other);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user