Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
311c0064
Unverified
Commit
311c0064
authored
Mar 05, 2024
by
Tirth
Committed by
GitHub
Mar 05, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds missing `style` to `PopupMenuButton` (#143392)
Adds missing `style` to `PopupMenuButton`. Fixes: #114709
parent
bb8fc6e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+12
-0
popup_menu_test.dart
packages/flutter/test/material/popup_menu_test.dart
+27
-0
No files found.
packages/flutter/lib/src/material/popup_menu.dart
View file @
311c0064
...
...
@@ -7,6 +7,7 @@ import 'package:flutter/rendering.dart';
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/widgets.dart'
;
import
'button_style.dart'
;
import
'color_scheme.dart'
;
import
'colors.dart'
;
import
'constants.dart'
;
...
...
@@ -1149,6 +1150,7 @@ class PopupMenuButton<T> extends StatefulWidget {
this
.
clipBehavior
=
Clip
.
none
,
this
.
useRootNavigator
=
false
,
this
.
popUpAnimationStyle
,
this
.
style
,
})
:
assert
(
!(
child
!=
null
&&
icon
!=
null
),
'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.
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
PopupMenuButtonState
<
T
>
createState
()
=>
PopupMenuButtonState
<
T
>();
}
...
...
@@ -1455,6 +1466,7 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
tooltip:
widget
.
tooltip
??
MaterialLocalizations
.
of
(
context
).
showMenuTooltip
,
onPressed:
widget
.
enabled
?
showButtonMenu
:
null
,
enableFeedback:
enableFeedback
,
style:
widget
.
style
,
);
}
}
...
...
packages/flutter/test/material/popup_menu_test.dart
View file @
311c0064
...
...
@@ -4060,6 +4060,33 @@ void main() {
expect
(
listViewportBounds
.
bottomRight
.
dy
,
lessThanOrEqualTo
(
windowSize
.
height
));
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment