@@ -1619,4 +1619,90 @@ void main() {
1619
1619
expect ((mergeableMaterial.children.first as MaterialSlice ).color, firstPanelColor);
1620
1620
expect ((mergeableMaterial.children.last as MaterialSlice ).color, secondPanelColor);
1621
1621
});
1622
+
1623
+ testWidgets ('ExpansionPanelList.materialGapSize defaults to 16.0' , (WidgetTester tester) async {
1624
+ await tester.pumpWidget (MaterialApp (
1625
+ home: SingleChildScrollView (
1626
+ child: ExpansionPanelList (
1627
+ children: < ExpansionPanel > [
1628
+ ExpansionPanel (
1629
+ canTapOnHeader: true ,
1630
+ body: const SizedBox .shrink (),
1631
+ headerBuilder: (BuildContext context, bool isExpanded) {
1632
+ return const SizedBox .shrink ();
1633
+ },
1634
+ )
1635
+ ],
1636
+ ),
1637
+ ),
1638
+ ));
1639
+
1640
+ final ExpansionPanelList expansionPanelList = tester.widget (find.byType (ExpansionPanelList ));
1641
+ expect (expansionPanelList.materialGapSize, 16 );
1642
+ });
1643
+
1644
+ testWidgets ('ExpansionPanelList respects materialGapSize' , (WidgetTester tester) async {
1645
+ Widget buildWidgetForTest ({double materialGapSize = 16 }) {
1646
+ return MaterialApp (
1647
+ home: SingleChildScrollView (
1648
+ child: ExpansionPanelList (
1649
+ materialGapSize: materialGapSize,
1650
+ children: < ExpansionPanel > [
1651
+ ExpansionPanel (
1652
+ isExpanded: true ,
1653
+ canTapOnHeader: true ,
1654
+ body: const SizedBox .shrink (),
1655
+ headerBuilder: (BuildContext context, bool isExpanded) {
1656
+ return const SizedBox .shrink ();
1657
+ },
1658
+ ),
1659
+ ExpansionPanel (
1660
+ canTapOnHeader: true ,
1661
+ body: const SizedBox .shrink (),
1662
+ headerBuilder: (BuildContext context, bool isExpanded) {
1663
+ return const SizedBox .shrink ();
1664
+ },
1665
+ ),
1666
+ ],
1667
+ ),
1668
+ ),
1669
+ );
1670
+ }
1671
+
1672
+ await tester.pumpWidget (buildWidgetForTest (materialGapSize: 0 ));
1673
+ await tester.pumpAndSettle ();
1674
+ final MergeableMaterial mergeableMaterial = tester.widget (find.byType (MergeableMaterial ));
1675
+ expect (mergeableMaterial.children.length, 3 );
1676
+ expect (mergeableMaterial.children.whereType <MaterialGap >().length, 1 );
1677
+ expect (mergeableMaterial.children.whereType <MaterialSlice >().length, 2 );
1678
+ for (final MergeableMaterialItem e in mergeableMaterial.children) {
1679
+ if (e is MaterialGap ) {
1680
+ expect (e.size, 0 );
1681
+ }
1682
+ }
1683
+
1684
+ await tester.pumpWidget (buildWidgetForTest (materialGapSize: 20 ));
1685
+ await tester.pumpAndSettle ();
1686
+ final MergeableMaterial mergeableMaterial2 = tester.widget (find.byType (MergeableMaterial ));
1687
+ expect (mergeableMaterial2.children.length, 3 );
1688
+ expect (mergeableMaterial2.children.whereType <MaterialGap >().length, 1 );
1689
+ expect (mergeableMaterial2.children.whereType <MaterialSlice >().length, 2 );
1690
+ for (final MergeableMaterialItem e in mergeableMaterial2.children) {
1691
+ if (e is MaterialGap ) {
1692
+ expect (e.size, 20 );
1693
+ }
1694
+ }
1695
+
1696
+ await tester.pumpWidget (buildWidgetForTest ());
1697
+ await tester.pumpAndSettle ();
1698
+ final MergeableMaterial mergeableMaterial3 = tester.widget (find.byType (MergeableMaterial ));
1699
+ expect (mergeableMaterial3.children.length, 3 );
1700
+ expect (mergeableMaterial3.children.whereType <MaterialGap >().length, 1 );
1701
+ expect (mergeableMaterial3.children.whereType <MaterialSlice >().length, 2 );
1702
+ for (final MergeableMaterialItem e in mergeableMaterial3.children) {
1703
+ if (e is MaterialGap ) {
1704
+ expect (e.size, 16 );
1705
+ }
1706
+ }
1707
+ });
1622
1708
}
0 commit comments