-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[material_ui] Keep ExpansionPanelList dividers when expanded with 0 materialGapSize (#183974) #12820
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
benji-farquhar
wants to merge
1
commit into
flutter:main
Choose a base branch
from
benji-farquhar:retain-expansion-panel-dividers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[material_ui] Keep ExpansionPanelList dividers when expanded with 0 materialGapSize (#183974) #12820
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
96 changes: 96 additions & 0 deletions
96
packages/material_ui/example/lib/expansion_panel/expansion_panel_list.2.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| // #region body | ||
| import 'package:material_ui/material_ui.dart'; | ||
|
|
||
| /// Flutter code sample for a flat [ExpansionPanelList] with divider separators. | ||
|
|
||
| void main() => runApp(const FlatExpansionPanelListExampleApp()); | ||
|
|
||
| class FlatExpansionPanelListExampleApp extends StatelessWidget { | ||
| const FlatExpansionPanelListExampleApp({super.key}); | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return MaterialApp( | ||
| home: Scaffold( | ||
| appBar: AppBar(title: const Text('Flat ExpansionPanelList Sample')), | ||
| body: const Center(child: FlatExpansionPanelListExample()), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| class FlatExpansionPanelListExample extends StatefulWidget { | ||
| const FlatExpansionPanelListExample({super.key}); | ||
|
|
||
| @override | ||
| State<FlatExpansionPanelListExample> createState() => | ||
| _FlatExpansionPanelListExampleState(); | ||
| } | ||
|
|
||
| class _FlatExpansionPanelListExampleState | ||
| extends State<FlatExpansionPanelListExample> { | ||
| final List<bool> _isExpanded = <bool>[false, false, false]; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) { | ||
| return SingleChildScrollView( | ||
| child: Padding( | ||
| padding: const .all(16.0), | ||
| child: Column( | ||
| children: <Widget>[ | ||
| const Padding( | ||
| padding: .only(bottom: 16.0), | ||
|
benji-farquhar marked this conversation as resolved.
|
||
| child: Text( | ||
| 'With materialGapSize set to 0, dividers between expanded panels are ' | ||
| 'preserved, creating a flat list appearance.', | ||
| textAlign: .center, | ||
| ), | ||
| ), | ||
| Card( | ||
| child: ExpansionPanelList( | ||
| materialGapSize: 0, | ||
| expandedHeaderPadding: .zero, | ||
|
benji-farquhar marked this conversation as resolved.
|
||
| expansionCallback: (int index, bool isExpanded) { | ||
| setState(() { | ||
| _isExpanded[index] = isExpanded; | ||
| }); | ||
| }, | ||
| children: <ExpansionPanel>[ | ||
| ExpansionPanel( | ||
| headerBuilder: (BuildContext context, bool isExpanded) { | ||
| return const ListTile(title: Text('Panel A')); | ||
| }, | ||
| body: const ListTile(title: Text('Content for Panel A')), | ||
| isExpanded: _isExpanded[0], | ||
| canTapOnHeader: true, | ||
| ), | ||
| ExpansionPanel( | ||
| headerBuilder: (BuildContext context, bool isExpanded) { | ||
| return const ListTile(title: Text('Panel B')); | ||
| }, | ||
| body: const ListTile(title: Text('Content for Panel B')), | ||
| isExpanded: _isExpanded[1], | ||
| canTapOnHeader: true, | ||
| ), | ||
| ExpansionPanel( | ||
| headerBuilder: (BuildContext context, bool isExpanded) { | ||
| return const ListTile(title: Text('Panel C')); | ||
| }, | ||
| body: const ListTile(title: Text('Content for Panel C')), | ||
| isExpanded: _isExpanded[2], | ||
| canTapOnHeader: true, | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| } | ||
| } | ||
| // #endregion body | ||
26 changes: 26 additions & 0 deletions
26
packages/material_ui/example/test/expansion_panel/expansion_panel_list.2_test.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Copyright 2013 The Flutter Authors | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| import 'package:flutter_test/flutter_test.dart'; | ||
| import 'package:material_ui/material_ui.dart'; | ||
| import 'package:material_ui_examples/expansion_panel/expansion_panel_list.2.dart' | ||
| as example; | ||
|
|
||
| void main() { | ||
| testWidgets( | ||
| 'Flat ExpansionPanelList preserves dividers with no MaterialGap', | ||
| (WidgetTester tester) async { | ||
| await tester.pumpWidget(const example.FlatExpansionPanelListExampleApp()); | ||
|
|
||
| await tester.tap(find.text('Panel A')); | ||
| await tester.pumpAndSettle(); | ||
|
|
||
| final MergeableMaterial mergeableMaterial = tester.widget( | ||
| find.byType(MergeableMaterial), | ||
| ); | ||
| expect(mergeableMaterial.children.whereType<MaterialGap>().length, 0); | ||
| expect(mergeableMaterial.hasDividers, true); | ||
| }, | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
packages/material_ui/pending_changelogs/expansion_panel_retain_dividers.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| changelog: | | ||
| - Keeps `ExpansionPanelList` dividers when expanded if `materialGapSize` is 0. | ||
| version: minor | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.