Skip to content

Commit 507c6a6

Browse files
committed
Fix ExpansionTile splash effect
1 parent 3c80df5 commit 507c6a6

File tree

3 files changed

+230
-95
lines changed

3 files changed

+230
-95
lines changed

packages/flutter/lib/src/material/expansion_tile.dart

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,9 @@ class ExpansionTile extends StatefulWidget {
469469

470470
/// {@macro flutter.material.Material.clipBehavior}
471471
///
472+
/// If this is not null and a custom collapsed or expanded shape is provided,
473+
/// specified clip behavior will be used to clip the expansion tile.
474+
///
472475
/// If this property is null, the [ExpansionTileThemeData.clipBehavior] is used. If that
473476
/// is also null, a [Clip.none] is used
474477
///
@@ -607,10 +610,11 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
607610
Widget _buildChildren(BuildContext context, Widget? child) {
608611
final ThemeData theme = Theme.of(context);
609612
final ExpansionTileThemeData expansionTileTheme = ExpansionTileTheme.of(context);
613+
final Color backgroundColor = _backgroundColor.value ?? expansionTileTheme.backgroundColor ?? Colors.transparent;
610614
final ShapeBorder expansionTileBorder = _border.value ?? const Border(
611-
top: BorderSide(color: Colors.transparent),
612-
bottom: BorderSide(color: Colors.transparent),
613-
);
615+
top: BorderSide(color: Colors.transparent),
616+
bottom: BorderSide(color: Colors.transparent),
617+
);
614618
final Clip clipBehavior = widget.clipBehavior ?? expansionTileTheme.clipBehavior ?? Clip.none;
615619
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
616620
final String onTapHint = _isExpanded
@@ -629,12 +633,14 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
629633
case TargetPlatform.windows:
630634
break;
631635
}
632-
return Container(
633-
clipBehavior: clipBehavior,
634-
decoration: ShapeDecoration(
635-
color: _backgroundColor.value ?? expansionTileTheme.backgroundColor ?? Colors.transparent,
636-
shape: expansionTileBorder,
637-
),
636+
637+
final Decoration decoration = ShapeDecoration(
638+
color: backgroundColor,
639+
shape: expansionTileBorder,
640+
);
641+
642+
final Widget expansionTile = Padding(
643+
padding: decoration.padding,
638644
child: Column(
639645
mainAxisSize: MainAxisSize.min,
640646
children: <Widget>[
@@ -666,6 +672,23 @@ class _ExpansionTileState extends State<ExpansionTile> with SingleTickerProvider
666672
],
667673
),
668674
);
675+
676+
final bool isShapeProvided = widget.shape != null || expansionTileTheme.shape != null
677+
|| widget.collapsedShape != null || expansionTileTheme.collapsedShape != null;
678+
679+
if (isShapeProvided) {
680+
return Material(
681+
clipBehavior: clipBehavior,
682+
color: backgroundColor,
683+
shape: expansionTileBorder,
684+
child: expansionTile,
685+
);
686+
}
687+
688+
return DecoratedBox(
689+
decoration: decoration,
690+
child: expansionTile,
691+
);
669692
}
670693

671694
@override

0 commit comments

Comments
 (0)