Commit f65dd3b
authored
Fix chip widgets don't the apply provided
fixes [`Chip.iconTheme` does not apply the icon theme](flutter/flutter#111828)
### Description
- Fix chip widgets that don't utilize the provided `iconTheme`.
- Prevent `iconTheme` with just color from overriding the default icon size.
- Add some missing M3 tests for the chip and chip theme properties.
### 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),
home: const Example(),
);
}
}
class Example extends StatefulWidget {
const Example({super.key});
@OverRide
State<Example> createState() => _ExampleState();
}
class _ExampleState extends State<Example> {
final bool _isEnable = true;
@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
RawChip(
iconTheme: const IconThemeData(color: Colors.amber),
avatar: const Icon(Icons.favorite_rounded),
label: const Text('RawChip'),
onPressed: () {},
isEnabled: _isEnable,
),
const Chip(
iconTheme: IconThemeData(color: Colors.amber),
avatar: Icon(Icons.favorite_rounded),
label: Text('Chip'),
// onDeleted: () {},
),
FilterChip(
iconTheme: const IconThemeData(color: Colors.amber),
avatar: const Icon(Icons.favorite_rounded),
label: const Text('FilterChip'),
selected: false,
onSelected: _isEnable ? (bool value) {} : null,
),
InputChip(
iconTheme: const IconThemeData(color: Colors.amber),
avatar: const Icon(Icons.favorite_rounded),
label: const Text('InputChip'),
isEnabled: _isEnable,
onPressed: () {},
),
ActionChip(
iconTheme: const IconThemeData(color: Colors.amber),
avatar: const Icon(Icons.favorite_rounded),
label: const Text('ActionChip'),
onPressed: _isEnable ? () {} : null,
),
ChoiceChip(
iconTheme: const IconThemeData(color: Colors.amber),
avatar: const Icon(Icons.favorite_rounded),
label: const Text('ChoiceChip'),
selected: false,
onSelected: _isEnable ? (bool value) {} : null,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: const Icon(Icons.add),
),
);
}
}
```
</details>
### Before

### After
iconTheme (#135751)1 parent fad8bda commit f65dd3b
File tree
10 files changed
+441
-39
lines changed- packages/flutter
- lib/src/material
- test/material
10 files changed
+441
-39
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
225 | 225 | | |
226 | 226 | | |
227 | 227 | | |
| 228 | + | |
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
659 | 659 | | |
660 | 660 | | |
661 | 661 | | |
| 662 | + | |
662 | 663 | | |
663 | 664 | | |
664 | 665 | | |
| |||
1219 | 1220 | | |
1220 | 1221 | | |
1221 | 1222 | | |
1222 | | - | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
1223 | 1227 | | |
1224 | 1228 | | |
1225 | 1229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| 238 | + | |
238 | 239 | | |
239 | 240 | | |
240 | 241 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
239 | 240 | | |
240 | 241 | | |
241 | 242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
47 | 57 | | |
48 | 58 | | |
49 | 59 | | |
| |||
349 | 359 | | |
350 | 360 | | |
351 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
352 | 387 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3570 | 3570 | | |
3571 | 3571 | | |
3572 | 3572 | | |
| 3573 | + | |
| 3574 | + | |
| 3575 | + | |
| 3576 | + | |
| 3577 | + | |
| 3578 | + | |
| 3579 | + | |
| 3580 | + | |
| 3581 | + | |
| 3582 | + | |
| 3583 | + | |
| 3584 | + | |
| 3585 | + | |
| 3586 | + | |
| 3587 | + | |
| 3588 | + | |
| 3589 | + | |
| 3590 | + | |
| 3591 | + | |
| 3592 | + | |
| 3593 | + | |
| 3594 | + | |
| 3595 | + | |
| 3596 | + | |
| 3597 | + | |
| 3598 | + | |
| 3599 | + | |
| 3600 | + | |
| 3601 | + | |
| 3602 | + | |
| 3603 | + | |
| 3604 | + | |
| 3605 | + | |
| 3606 | + | |
3573 | 3607 | | |
3574 | 3608 | | |
3575 | 3609 | | |
| |||
0 commit comments