Skip to content

Commit 1e843bb

Browse files
authored
fix paint order of ink feature (flutter#59108)
1 parent 82a6f9b commit 1e843bb

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,12 @@ class _AppBarState extends State<AppBar> {
684684
fit: StackFit.passthrough,
685685
children: <Widget>[
686686
widget.flexibleSpace,
687-
appBar,
687+
// Creates a material widget to prevent the flexibleSpace from swallow
688+
// the ink splash effect.
689+
Material(
690+
type: MaterialType.transparency,
691+
child: appBar,
692+
),
688693
],
689694
);
690695
}

packages/flutter/test/material/app_bar_test.dart

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:flutter/rendering.dart';
1010
import 'package:flutter/services.dart';
1111
import 'package:flutter_test/flutter_test.dart';
1212

13+
import '../rendering/mock_canvas.dart';
1314
import '../widgets/semantics_tester.dart';
1415

1516
Widget buildSliverAppBarApp({
@@ -1103,6 +1104,48 @@ void main() {
11031104
expect(find.byIcon(Icons.menu), findsNothing);
11041105
});
11051106

1107+
testWidgets('AppBar ink splash draw on the correct canvas', (WidgetTester tester) async {
1108+
// This is a regression test for https://github.com/flutter/flutter/issues/58665
1109+
final Key key = UniqueKey();
1110+
await tester.pumpWidget(
1111+
MaterialApp(
1112+
home: Center(
1113+
child: AppBar(
1114+
title: const Text('Abc'),
1115+
actions: <Widget>[
1116+
IconButton(
1117+
key: key,
1118+
icon: const Icon(Icons.add_circle),
1119+
tooltip: 'First button',
1120+
onPressed: () {},
1121+
),
1122+
],
1123+
flexibleSpace: DecoratedBox(
1124+
decoration: BoxDecoration(
1125+
gradient: LinearGradient(
1126+
begin: const Alignment(0.0, -1.0),
1127+
end: const Alignment(-0.04, 1.0),
1128+
colors: <Color>[Colors.blue.shade500, Colors.blue.shade800],
1129+
),
1130+
),
1131+
),
1132+
),
1133+
),
1134+
),
1135+
);
1136+
final RenderObject painter = tester.renderObject(
1137+
find.descendant(
1138+
of: find.descendant(
1139+
of: find.byType(AppBar),
1140+
matching: find.byType(Stack),
1141+
),
1142+
matching: find.byType(Material)
1143+
)
1144+
);
1145+
await tester.tap(find.byKey(key));
1146+
expect(painter, paints..save()..translate()..save()..translate()..circle(x: 24.0, y: 28.0));
1147+
});
1148+
11061149
testWidgets('AppBar handles loose children 0', (WidgetTester tester) async {
11071150
final GlobalKey key = GlobalKey();
11081151
await tester.pumpWidget(

0 commit comments

Comments
 (0)