-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Steps to reproduce
Set ExpansionPanel.canTapOnHeader = true, ExpansionPanelList.expandIconColor will be ignored, and the IconButtonTheme.foregroundColor disabled state will instead be used.
This issue says it is working as intended because it "is grey because it is disabled when canTapOnHeader is true", however, it shouldn't appear disabled as it is an indication to the user that it is expandable, and even if that particular button is disabled, it should appear enabled since tapping there will perform the expand/collapse action. It is a visual-only bug.
Expected results
ExpandIcon's color should be expandIconColor even when canTapOnHeader is true.
Actual results
expandIconColor is not used if canTapOnHeader is true, and the iconButtonTheme.foregroundColor disabled state is used.
Code sample
Code sample
import 'package:flutter/material.dart';
/// Flutter code sample for [ExpansionPanelList].
void main() => runApp(const ExpansionPanelListExampleApp());
class ExpansionPanelListExampleApp extends StatelessWidget {
const ExpansionPanelListExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('ExpansionPanelList Sample')),
body: const ExpansionPanelListExample(),
),
);
}
}
// stores ExpansionPanel state information
class Item {
Item({
required this.expandedValue,
required this.headerValue,
required this.value,
required this.canTapOnHeader,
});
String expandedValue;
String headerValue;
int value;
bool canTapOnHeader;
}
List<Item> generateItems(int numberOfItems) {
return List<Item>.generate(numberOfItems, (int index) {
bool canTapOnHeader = index > 3;
return Item(
headerValue: 'Panel $index canTapOnHeader=${canTapOnHeader.toString()}',
expandedValue: 'This is item number $index',
value: index,
canTapOnHeader: canTapOnHeader,
);
});
}
class ExpansionPanelListExample extends StatefulWidget {
const ExpansionPanelListExample({super.key});
@override
State<ExpansionPanelListExample> createState() =>
_ExpansionPanelListExampleState();
}
class _ExpansionPanelListExampleState extends State<ExpansionPanelListExample> {
final List<Item> _data = generateItems(8);
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
child: Container(
child: _buildPanel(),
),
);
}
Widget _buildPanel() {
return ExpansionPanelList.radio(
children: _data.map<ExpansionPanelRadio>((Item item) {
return ExpansionPanelRadio(
headerBuilder: (BuildContext context, bool isExpanded) {
return ListTile(
title: Text(item.headerValue),
);
},
body: ListTile(
title: Text(item.expandedValue),
),
value: item.value,
canTapOnHeader: item.canTapOnHeader,
);
}).toList(),
expandIconColor: Colors.red,
);
}
}
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[Paste your output here]Metadata
Metadata
Assignees
Labels
Type
Projects
Status