Unverified Commit 2e3d3e65 authored by Greg Spencer's avatar Greg Spencer Committed by GitHub

Revert "ListTile Material Ripple and Shape Patch (#73618)" (#74335)

This reverts commit 024c49da because it breaks Google internal tests.
parent e2e3976a
......@@ -12,7 +12,6 @@ import 'colors.dart';
import 'constants.dart';
import 'debug.dart';
import 'divider.dart';
import 'ink_decoration.dart';
import 'ink_well.dart';
import 'material_state.dart';
import 'theme.dart';
......@@ -110,7 +109,7 @@ class ListTileTheme extends InheritedTheme {
final bool dense;
/// {@template flutter.material.ListTileTheme.shape}
/// If specified, [shape] defines the [ListTile]'s shape.
/// If specified, [shape] defines the shape of the [ListTile]'s [InkWell] border.
/// {@endtemplate}
final ShapeBorder? shape;
......@@ -839,12 +838,13 @@ class ListTile extends StatelessWidget {
/// widgets within a [Theme].
final VisualDensity? visualDensity;
/// The tile's shape.
/// The shape of the tile's [InkWell].
///
/// Defines the tile's [InkWell.customBorder] and [Ink.decoration] shape.
/// Defines the tile's [InkWell.customBorder].
///
/// If this property is null then [ListTileTheme.shape] is used.
/// If that's null then a rectangular [Border] will be used.
/// If this property is null then [CardTheme.shape] of [ThemeData.cardTheme]
/// is used. If that's null then the shape will be a [RoundedRectangleBorder]
/// with a circular corner radius of 4.0.
final ShapeBorder? shape;
/// The tile's internal padding.
......@@ -1183,11 +1183,8 @@ class ListTile extends StatelessWidget {
child: Semantics(
selected: selected,
enabled: enabled,
child: Ink(
decoration: ShapeDecoration(
shape: shape ?? tileTheme.shape ?? const Border(),
color: _tileBackgroundColor(tileTheme),
),
child: ColoredBox(
color: _tileBackgroundColor(tileTheme),
child: SafeArea(
top: false,
bottom: false,
......
......@@ -577,13 +577,7 @@ abstract class RenderSliverMultiBoxAdaptor extends RenderSliver
@override
void applyPaintTransform(RenderBox child, Matrix4 transform) {
final SliverMultiBoxAdaptorParentData childParentData = child.parentData! as SliverMultiBoxAdaptorParentData;
if (childParentData.index == null) {
// If the child has no index, such as with the prototype of a
// SliverPrototypeExtentList, then it is not visible, so we give it a
// zero transform to prevent it from painting.
transform.setZero();
} else if (_keepAliveBucket.containsKey(childParentData.index)) {
if (_keepAliveBucket.containsKey(indexOf(child))) {
// It is possible that widgets under kept alive children want to paint
// themselves. For example, the Material widget tries to paint all
// InkFeatures under its subtree as long as they are not disposed. In
......
......@@ -129,7 +129,7 @@ void main() {
)
);
final Rect paddingRect = tester.getRect(find.byType(SafeArea));
final Rect paddingRect = tester.getRect(find.byType(Padding));
final Rect checkboxRect = tester.getRect(find.byType(Checkbox));
final Rect titleRect = tester.getRect(find.text('Title'));
......@@ -241,34 +241,35 @@ void main() {
});
testWidgets('CheckboxListTile respects tileColor', (WidgetTester tester) async {
final Color tileColor = Colors.red.shade500;
const Color tileColor = Colors.black;
await tester.pumpWidget(
wrap(
child: Center(
child: const Center(
child: CheckboxListTile(
value: false,
onChanged: null,
title: const Text('Title'),
title: Text('Title'),
tileColor: tileColor,
),
),
),
);
expect(find.byType(Material), paints..path(color: tileColor));
final ColoredBox coloredBox = tester.firstWidget(find.byType(ColoredBox));
expect(coloredBox.color, equals(tileColor));
});
testWidgets('CheckboxListTile respects selectedTileColor', (WidgetTester tester) async {
final Color selectedTileColor = Colors.green.shade500;
const Color selectedTileColor = Colors.black;
await tester.pumpWidget(
wrap(
child: Center(
child: const Center(
child: CheckboxListTile(
value: false,
onChanged: null,
title: const Text('Title'),
title: Text('Title'),
selected: true,
selectedTileColor: selectedTileColor,
),
......@@ -276,6 +277,7 @@ void main() {
),
);
expect(find.byType(Material), paints..path(color: selectedTileColor));
final ColoredBox coloredBox = tester.firstWidget(find.byType(ColoredBox));
expect(coloredBox.color, equals(selectedTileColor));
});
}
......@@ -9,7 +9,6 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart';
import '../rendering/mock_canvas.dart';
import '../widgets/semantics_tester.dart';
......@@ -629,7 +628,7 @@ void main() {
)
);
final Rect paddingRect = tester.getRect(find.byType(SafeArea));
final Rect paddingRect = tester.getRect(find.byType(Padding));
final Rect radioRect = tester.getRect(find.byType(radioType));
final Rect titleRect = tester.getRect(find.text('Title'));
......@@ -669,36 +668,37 @@ void main() {
});
testWidgets('RadioListTile respects tileColor', (WidgetTester tester) async {
final Color tileColor = Colors.red.shade500;
const Color tileColor = Colors.red;
await tester.pumpWidget(
wrap(
child: Center(
child: const Center(
child: RadioListTile<bool>(
value: false,
groupValue: true,
onChanged: null,
title: const Text('Title'),
title: Text('Title'),
tileColor: tileColor,
),
),
),
);
expect(find.byType(Material), paints..path(color: tileColor));
final ColoredBox coloredBox = tester.firstWidget(find.byType(ColoredBox));
expect(coloredBox.color, tileColor);
});
testWidgets('RadioListTile respects selectedTileColor', (WidgetTester tester) async {
final Color selectedTileColor = Colors.green.shade500;
const Color selectedTileColor = Colors.black;
await tester.pumpWidget(
wrap(
child: Center(
child: const Center(
child: RadioListTile<bool>(
value: false,
groupValue: true,
onChanged: null,
title: const Text('Title'),
title: Text('Title'),
selected: true,
selectedTileColor: selectedTileColor,
),
......@@ -706,6 +706,7 @@ void main() {
),
);
expect(find.byType(Material), paints..path(color: selectedTileColor));
final ColoredBox coloredBox = tester.firstWidget(find.byType(ColoredBox));
expect(coloredBox.color, equals(selectedTileColor));
});
}
......@@ -359,34 +359,35 @@ void main() {
});
testWidgets('SwitchListTile respects tileColor', (WidgetTester tester) async {
final Color tileColor = Colors.red.shade500;
const Color tileColor = Colors.red;
await tester.pumpWidget(
wrap(
child: Center(
child: const Center(
child: SwitchListTile(
value: false,
onChanged: null,
title: const Text('Title'),
title: Text('Title'),
tileColor: tileColor,
),
),
),
);
expect(find.byType(Material), paints..path(color: tileColor));
final ColoredBox coloredBox = tester.firstWidget(find.byType(ColoredBox));
expect(coloredBox.color, tileColor);
});
testWidgets('SwitchListTile respects selectedTileColor', (WidgetTester tester) async {
final Color selectedTileColor = Colors.green.shade500;
const Color selectedTileColor = Colors.black;
await tester.pumpWidget(
wrap(
child: Center(
child: const Center(
child: SwitchListTile(
value: false,
onChanged: null,
title: const Text('Title'),
title: Text('Title'),
selected: true,
selectedTileColor: selectedTileColor,
),
......@@ -394,7 +395,8 @@ void main() {
),
);
expect(find.byType(Material), paints..path(color: selectedTileColor));
final ColoredBox coloredBox = tester.firstWidget(find.byType(ColoredBox));
expect(coloredBox.color, equals(selectedTileColor));
});
}
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/widgets.dart';
......@@ -22,14 +21,14 @@ class TestItem extends StatelessWidget {
}
}
Widget buildFrame({ int? count, double? width, double? height, Axis? scrollDirection, Key? prototypeKey }) {
Widget buildFrame({ int? count, double? width, double? height, Axis? scrollDirection }) {
return Directionality(
textDirection: TextDirection.ltr,
child: CustomScrollView(
scrollDirection: scrollDirection ?? Axis.vertical,
slivers: <Widget>[
SliverPrototypeExtentList(
prototypeItem: TestItem(item: -1, width: width, height: height, key: prototypeKey),
prototypeItem: TestItem(item: -1, width: width, height: height),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) => TestItem(item: index),
childCount: count,
......@@ -137,18 +136,4 @@ void main() {
for (int i = 1; i < 10; i += 1)
expect(find.text('Item $i'), findsOneWidget);
});
testWidgets('SliverPrototypeExtentList prototypeItem paint transform is zero.', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/67117
// This test ensures that the SliverPrototypeExtentList does not cause an
// assertion error when calculating the paint transform of its prototypeItem.
// The paint transform of the prototypeItem should be zero, since it is not visible.
final GlobalKey prototypeKey = GlobalKey();
await tester.pumpWidget(buildFrame(count: 20, height: 100.0, prototypeKey: prototypeKey));
final RenderObject scrollView = tester.renderObject(find.byType(CustomScrollView));
final RenderObject prototype = prototypeKey.currentContext!.findRenderObject()!;
expect(prototype.getTransformTo(scrollView), Matrix4.zero());
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment