@@ -475,8 +475,11 @@ class ExpansionTile extends StatefulWidget {
475
475
476
476
/// {@macro flutter.material.Material.clipBehavior}
477
477
///
478
+ /// If this is not null and a custom collapsed or expanded shape is provided,
479
+ /// the value of [clipBehavior] will be used to clip the expansion tile.
480
+ ///
478
481
/// If this property is null, the [ExpansionTileThemeData.clipBehavior] is used. If that
479
- /// is also null, a [Clip.none] is used
482
+ /// is also null, defaults to [Clip.antiAlias] .
480
483
///
481
484
/// See also:
482
485
///
@@ -656,11 +659,12 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
656
659
Widget _buildChildren (BuildContext context, Widget ? child) {
657
660
final ThemeData theme = Theme .of (context);
658
661
final ExpansionTileThemeData expansionTileTheme = ExpansionTileTheme .of (context);
662
+ final Color backgroundColor = _backgroundColor.value ?? expansionTileTheme.backgroundColor ?? Colors .transparent;
659
663
final ShapeBorder expansionTileBorder = _border.value ?? const Border (
660
- top: BorderSide (color: Colors .transparent),
661
- bottom: BorderSide (color: Colors .transparent),
662
- );
663
- final Clip clipBehavior = widget.clipBehavior ?? expansionTileTheme.clipBehavior ?? Clip .none ;
664
+ top: BorderSide (color: Colors .transparent),
665
+ bottom: BorderSide (color: Colors .transparent),
666
+ );
667
+ final Clip clipBehavior = widget.clipBehavior ?? expansionTileTheme.clipBehavior ?? Clip .antiAlias ;
664
668
final MaterialLocalizations localizations = MaterialLocalizations .of (context);
665
669
final String onTapHint = _isExpanded
666
670
? localizations.expansionTileExpandedTapHint
@@ -679,12 +683,13 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
679
683
break ;
680
684
}
681
685
682
- return Container (
683
- clipBehavior: clipBehavior,
684
- decoration: ShapeDecoration (
685
- color: _backgroundColor.value ?? expansionTileTheme.backgroundColor ?? Colors .transparent,
686
- shape: expansionTileBorder,
687
- ),
686
+ final Decoration decoration = ShapeDecoration (
687
+ color: backgroundColor,
688
+ shape: expansionTileBorder,
689
+ );
690
+
691
+ final Widget tile = Padding (
692
+ padding: decoration.padding,
688
693
child: Column (
689
694
mainAxisSize: MainAxisSize .min,
690
695
children: < Widget > [
@@ -720,6 +725,23 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
720
725
],
721
726
),
722
727
);
728
+
729
+ final bool isShapeProvided = widget.shape != null || expansionTileTheme.shape != null
730
+ || widget.collapsedShape != null || expansionTileTheme.collapsedShape != null ;
731
+
732
+ if (isShapeProvided) {
733
+ return Material (
734
+ clipBehavior: clipBehavior,
735
+ color: backgroundColor,
736
+ shape: expansionTileBorder,
737
+ child: tile,
738
+ );
739
+ }
740
+
741
+ return DecoratedBox (
742
+ decoration: decoration,
743
+ child: tile,
744
+ );
723
745
}
724
746
725
747
@override
0 commit comments