Commit 038ec62
authored
Add
fixes [Update `CheckedPopupMenuItem�` for Material 3](flutter/flutter#128576)
### Description
- This adds the missing ``CheckedPopupMenuItem�.labelTextStyle` parameter
- Fixes default text style for `CheckedPopupMenuItem�`.
It used `ListTile`'s `bodyLarge` instead of `LabelLarge` similar to `PopupMenuItem`.
### Code sample
<details>
<summary>expand to view the code sample</summary>
```dart
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@OverRide
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,
textTheme: const TextTheme(
labelLarge: TextStyle(
fontWeight: FontWeight.bold,
fontStyle: FontStyle.italic,
letterSpacing: 5.0,
),
),
),
home: const Example(),
);
}
}
class Example extends StatelessWidget {
const Example({super.key});
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Sample'),
actions: <Widget>[
PopupMenuButton<String>(
icon: const Icon(Icons.more_vert),
itemBuilder: (BuildContext context) => <PopupMenuEntry<String>>[
const CheckedPopupMenuItem<String>(
// labelTextStyle: MaterialStateProperty.resolveWith(
// (Set<MaterialState> states) {
// if (states.contains(MaterialState.selected)) {
// return const TextStyle(
// color: Colors.red,
// fontStyle: FontStyle.italic,
// fontWeight: FontWeight.bold,
// );
// }
// return const TextStyle(
// color: Colors.amber,
// fontStyle: FontStyle.italic,
// fontWeight: FontWeight.bold,
// );
// }),
child: Text('Mild'),
),
const CheckedPopupMenuItem<String>(
checked: true,
// labelTextStyle: MaterialStateProperty.resolveWith(
// (Set<MaterialState> states) {
// if (states.contains(MaterialState.selected)) {
// return const TextStyle(
// color: Colors.red,
// fontStyle: FontStyle.italic,
// fontWeight: FontWeight.bold,
// );
// }
// return const TextStyle(
// color: Colors.amber,
// fontStyle: FontStyle.italic,
// fontWeight: FontWeight.bold,
// );
// }),
child: Text('Spicy'),
),
const PopupMenuDivider(),
const PopupMenuItem<String>(
value: 'Close',
child: Text('Close'),
),
],
)
],
),
);
}
}
```
</details>
### Customized `textTheme.labelLarge` text theme.
| Before | After |
| --------------- | --------------- |
| <img src="https://github.com/flutter/flutter/assets/48603081/2672438d-b2da-479b-a5d3-d239ef646365" /> | <img src="https://github.com/flutter/flutter/assets/48603081/b9f83719-dede-4c2f-8247-18f74e63eb29" /> |
### New `CheckedPopupMenuItem�.labelTextStyle` parameter with material states support
<img src="https://github.com/flutter/flutter/assets/48603081/ef0a88aa-9811-42b1-a3aa-53b90c8d43fb" height="450" />CheckedPopupMenuItem.labelTextStyle and update default text style for Material 3 (#131060)1 parent 79033ed commit 038ec62
3 files changed
Lines changed: 178 additions & 9 deletions
File tree
- packages/flutter
- lib/src/material
- test/material
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
| 478 | + | |
478 | 479 | | |
479 | 480 | | |
480 | 481 | | |
| |||
529 | 530 | | |
530 | 531 | | |
531 | 532 | | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
532 | 542 | | |
533 | 543 | | |
534 | 544 | | |
| 545 | + | |
535 | 546 | | |
536 | 547 | | |
537 | 548 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3307 | 3307 | | |
3308 | 3308 | | |
3309 | 3309 | | |
| 3310 | + | |
| 3311 | + | |
| 3312 | + | |
| 3313 | + | |
| 3314 | + | |
| 3315 | + | |
| 3316 | + | |
| 3317 | + | |
| 3318 | + | |
| 3319 | + | |
| 3320 | + | |
| 3321 | + | |
| 3322 | + | |
| 3323 | + | |
| 3324 | + | |
| 3325 | + | |
| 3326 | + | |
| 3327 | + | |
| 3328 | + | |
| 3329 | + | |
| 3330 | + | |
| 3331 | + | |
| 3332 | + | |
| 3333 | + | |
| 3334 | + | |
| 3335 | + | |
| 3336 | + | |
| 3337 | + | |
| 3338 | + | |
| 3339 | + | |
| 3340 | + | |
| 3341 | + | |
| 3342 | + | |
| 3343 | + | |
| 3344 | + | |
| 3345 | + | |
| 3346 | + | |
| 3347 | + | |
| 3348 | + | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
| 3352 | + | |
| 3353 | + | |
| 3354 | + | |
| 3355 | + | |
| 3356 | + | |
| 3357 | + | |
| 3358 | + | |
| 3359 | + | |
| 3360 | + | |
| 3361 | + | |
| 3362 | + | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
| 3384 | + | |
| 3385 | + | |
| 3386 | + | |
| 3387 | + | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
| 3408 | + | |
| 3409 | + | |
| 3410 | + | |
| 3411 | + | |
| 3412 | + | |
| 3413 | + | |
| 3414 | + | |
| 3415 | + | |
| 3416 | + | |
| 3417 | + | |
| 3418 | + | |
| 3419 | + | |
| 3420 | + | |
3310 | 3421 | | |
3311 | 3422 | | |
3312 | 3423 | | |
| |||
3377 | 3488 | | |
3378 | 3489 | | |
3379 | 3490 | | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + | |
| 3494 | + | |
| 3495 | + | |
| 3496 | + | |
| 3497 | + | |
Lines changed: 49 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
152 | 159 | | |
153 | 160 | | |
154 | 161 | | |
| |||
181 | 188 | | |
182 | 189 | | |
183 | 190 | | |
184 | | - | |
| 191 | + | |
185 | 192 | | |
186 | 193 | | |
187 | 194 | | |
188 | 195 | | |
189 | 196 | | |
190 | | - | |
191 | | - | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
192 | 200 | | |
193 | | - | |
| 201 | + | |
194 | 202 | | |
195 | 203 | | |
196 | 204 | | |
197 | 205 | | |
198 | 206 | | |
199 | | - | |
| 207 | + | |
200 | 208 | | |
201 | 209 | | |
202 | 210 | | |
| |||
217 | 225 | | |
218 | 226 | | |
219 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
220 | 236 | | |
221 | 237 | | |
222 | 238 | | |
| |||
251 | 267 | | |
252 | 268 | | |
253 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
254 | 277 | | |
255 | 278 | | |
256 | 279 | | |
| |||
278 | 301 | | |
279 | 302 | | |
280 | 303 | | |
281 | | - | |
| 304 | + | |
282 | 305 | | |
283 | 306 | | |
284 | 307 | | |
285 | 308 | | |
286 | 309 | | |
287 | 310 | | |
288 | | - | |
| 311 | + | |
289 | 312 | | |
290 | 313 | | |
291 | 314 | | |
292 | | - | |
| 315 | + | |
293 | 316 | | |
294 | 317 | | |
295 | 318 | | |
296 | 319 | | |
297 | 320 | | |
298 | 321 | | |
299 | | - | |
| 322 | + | |
300 | 323 | | |
301 | 324 | | |
302 | 325 | | |
| |||
315 | 338 | | |
316 | 339 | | |
317 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
318 | 349 | | |
319 | 350 | | |
320 | 351 | | |
| |||
354 | 385 | | |
355 | 386 | | |
356 | 387 | | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
357 | 393 | | |
358 | 394 | | |
359 | 395 | | |
| |||
399 | 435 | | |
400 | 436 | | |
401 | 437 | | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
402 | 442 | | |
403 | 443 | | |
404 | 444 | | |
| |||
0 commit comments