Unverified Commit 240d2093 authored by Ren You's avatar Ren You Committed by GitHub

Revert "Refactored ListTileTheme: ListTileThemeData, ThemeData.listThemeData (#91449)" (#91811)

This reverts commit 94ff5202.
parent dc479794
...@@ -125,7 +125,7 @@ class AboutListTile extends StatelessWidget { ...@@ -125,7 +125,7 @@ class AboutListTile extends StatelessWidget {
/// Whether this list tile is part of a vertically dense list. /// Whether this list tile is part of a vertically dense list.
/// ///
/// If this property is null, then its value is based on [ListTileThemeData.dense]. /// If this property is null, then its value is based on [ListTileTheme.dense].
/// ///
/// Dense list tiles default to a smaller height. /// Dense list tiles default to a smaller height.
final bool? dense; final bool? dense;
......
...@@ -214,7 +214,7 @@ class CheckboxListTile extends StatelessWidget { ...@@ -214,7 +214,7 @@ class CheckboxListTile extends StatelessWidget {
/// Whether this list tile is part of a vertically dense list. /// Whether this list tile is part of a vertically dense list.
/// ///
/// If this property is null then its value is based on [ListTileThemeData.dense]. /// If this property is null then its value is based on [ListTileTheme.dense].
final bool? dense; final bool? dense;
/// Whether to render icons and text in the [activeColor]. /// Whether to render icons and text in the [activeColor].
...@@ -252,7 +252,7 @@ class CheckboxListTile extends StatelessWidget { ...@@ -252,7 +252,7 @@ class CheckboxListTile extends StatelessWidget {
/// If tristate is false (the default), [value] must not be null. /// If tristate is false (the default), [value] must not be null.
final bool tristate; final bool tristate;
/// {@macro flutter.material.ListTile.shape} /// {@macro flutter.material.ListTileTheme.shape}
final ShapeBorder? shape; final ShapeBorder? shape;
/// If non-null, defines the background color when [CheckboxListTile.selected] is true. /// If non-null, defines the background color when [CheckboxListTile.selected] is true.
......
...@@ -21,7 +21,7 @@ const Duration _kExpand = Duration(milliseconds: 200); ...@@ -21,7 +21,7 @@ const Duration _kExpand = Duration(milliseconds: 200);
/// [ExpansionTile] to save and restore its expanded state when it is scrolled /// [ExpansionTile] to save and restore its expanded state when it is scrolled
/// in and out of view. /// in and out of view.
/// ///
/// This class overrides the [ListTileThemeData.iconColor] and [ListTileThemeData.textColor] /// This class overrides the [ListTileTheme.iconColor] and [ListTileTheme.textColor]
/// theme properties for its [ListTile]. These colors animate between values when /// theme properties for its [ListTile]. These colors animate between values when
/// the tile is expanded and collapsed: between [iconColor], [collapsedIconColor] and /// the tile is expanded and collapsed: between [iconColor], [collapsedIconColor] and
/// between [textColor] and [collapsedTextColor]. /// between [textColor] and [collapsedTextColor].
...@@ -176,23 +176,23 @@ class ExpansionTile extends StatefulWidget { ...@@ -176,23 +176,23 @@ class ExpansionTile extends StatefulWidget {
/// The icon color of tile's expansion arrow icon when the sublist is expanded. /// The icon color of tile's expansion arrow icon when the sublist is expanded.
/// ///
/// Used to override to the [ListTileThemeData.iconColor]. /// Used to override to the [ListTileTheme.iconColor].
final Color? iconColor; final Color? iconColor;
/// The icon color of tile's expansion arrow icon when the sublist is collapsed. /// The icon color of tile's expansion arrow icon when the sublist is collapsed.
/// ///
/// Used to override to the [ListTileThemeData.iconColor]. /// Used to override to the [ListTileTheme.iconColor].
final Color? collapsedIconColor; final Color? collapsedIconColor;
/// The color of the tile's titles when the sublist is expanded. /// The color of the tile's titles when the sublist is expanded.
/// ///
/// Used to override to the [ListTileThemeData.textColor]. /// Used to override to the [ListTileTheme.textColor].
final Color? textColor; final Color? textColor;
/// The color of the tile's titles when the sublist is collapsed. /// The color of the tile's titles when the sublist is collapsed.
/// ///
/// Used to override to the [ListTileThemeData.textColor]. /// Used to override to the [ListTileTheme.textColor].
final Color? collapsedTextColor; final Color? collapsedTextColor;
/// Typically used to force the expansion arrow icon to the tile's leading or trailing edge. /// Typically used to force the expansion arrow icon to the tile's leading or trailing edge.
......
...@@ -3,9 +3,7 @@ ...@@ -3,9 +3,7 @@
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:math' as math; import 'dart:math' as math;
import 'dart:ui' show lerpDouble;
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
...@@ -32,247 +30,41 @@ enum ListTileStyle { ...@@ -32,247 +30,41 @@ enum ListTileStyle {
drawer, drawer,
} }
/// Where to place the control in widgets that use [ListTile] to position a /// An inherited widget that defines color and style parameters for [ListTile]s
/// control next to a label. /// in this widget's subtree.
///
/// See also:
///
/// * [CheckboxListTile], which combines a [ListTile] with a [Checkbox].
/// * [RadioListTile], which combines a [ListTile] with a [Radio] button.
/// * [SwitchListTile], which combines a [ListTile] with a [Switch].
/// * [ExpansionTile], which combines a [ListTile] with a button that expands
/// or collapses the tile to reveal or hide the children.
enum ListTileControlAffinity {
/// Position the control on the leading edge, and the secondary widget, if
/// any, on the trailing edge.
leading,
/// Position the control on the trailing edge, and the secondary widget, if
/// any, on the leading edge.
trailing,
/// Position the control relative to the text in the fashion that is typical
/// for the current platform, and place the secondary widget on the opposite
/// side.
platform,
}
/// Used with [ListTileTheme] to define default property values for
/// descendant [ListTile] widgets, as well as classes that build
/// [ListTile]s, like [CheckboxListTile], [RadioListTile], and
/// [SwitchListTile].
///
/// Descendant widgets obtain the current [ListTileThemeData] object
/// using `ListTileTheme.of(context)`. Instances of
/// [ListTileThemeData] can be customized with
/// [ListTileThemeData.copyWith].
///
/// A [ListTileThemeData] is often specified as part of the
/// overall [Theme] with [ThemeData.listTileTheme].
///
/// All [ListTileThemeData] properties are `null` by default.
/// When a theme property is null, the [ListTile] will provide its own
/// default based on the overall [Theme]'s textTheme and
/// colorScheme. See the individual [ListTile] properties for details.
///
/// The [Drawer] widget specifies a list tile theme for its children that
/// defines [style] to be [ListTileStyle.drawer].
/// ///
/// See also: /// Values specified here are used for [ListTile] properties that are not given
/// an explicit non-null value.
/// ///
/// * [ThemeData], which describes the overall theme information for the /// The [Drawer] widget specifies a tile theme for its children which sets
/// application. /// [style] to [ListTileStyle.drawer].
@immutable class ListTileTheme extends InheritedTheme {
class ListTileThemeData with Diagnosticable { /// Creates a list tile theme that controls the color and style parameters for
/// Creates a [ListTileThemeData]. /// [ListTile]s.
const ListTileThemeData ({ const ListTileTheme({
this.dense, Key? key,
this.dense = false,
this.shape, this.shape,
this.style, this.style = ListTileStyle.list,
this.selectedColor, this.selectedColor,
this.iconColor, this.iconColor,
this.textColor, this.textColor,
this.contentPadding, this.contentPadding,
this.tileColor, this.tileColor,
this.selectedTileColor, this.selectedTileColor,
this.enableFeedback,
this.horizontalTitleGap, this.horizontalTitleGap,
this.minVerticalPadding, this.minVerticalPadding,
this.minLeadingWidth, this.minLeadingWidth,
this.enableFeedback, required Widget child,
}); }) : super(key: key, child: child);
/// Overrides the default value of [ListTile.dense].
final bool? dense;
/// Overrides the default value of [ListTile.shape].
final ShapeBorder? shape;
/// Overrides the default value of [ListTile.style].
final ListTileStyle? style;
/// Overrides the default value of [ListTile.selectedColor].
final Color? selectedColor;
/// Overrides the default value of [ListTile.iconColor].
final Color? iconColor;
/// Overrides the default value of [ListTile.textColor].
final Color? textColor;
/// Overrides the default value of [ListTile.contentPadding].
final EdgeInsetsGeometry? contentPadding;
/// Overrides the default value of [ListTile.tileColor].
final Color? tileColor;
/// Overrides the default value of [ListTile.selectedTileColor].
final Color? selectedTileColor;
/// Overrides the default value of [ListTile.horizontalTitleGap].
final double? horizontalTitleGap;
/// Overrides the default value of [ListTile.minVerticalPadding].
final double? minVerticalPadding;
/// Overrides the default value of [ListTile.minLeadingWidth].
final double? minLeadingWidth;
/// Overrides the default value of [ListTile.enableFeedback].
final bool? enableFeedback;
/// Creates a copy of this object with the given fields replaced with the
/// new values.
ListTileThemeData copyWith({
bool? dense,
ShapeBorder? shape,
ListTileStyle? style,
Color? selectedColor,
Color? iconColor,
Color? textColor,
EdgeInsetsGeometry? contentPadding,
Color? tileColor,
Color? selectedTileColor,
double? horizontalTitleGap,
double? minVerticalPadding,
double? minLeadingWidth,
bool? enableFeedback,
}) {
return ListTileThemeData(
dense: dense ?? this.dense,
shape: shape ?? this.shape,
style: style ?? this.style,
selectedColor: selectedColor ?? this.selectedColor,
iconColor: iconColor ?? this.iconColor,
textColor: textColor ?? this.textColor,
contentPadding: contentPadding ?? this.contentPadding,
tileColor: tileColor ?? this.tileColor,
selectedTileColor: selectedTileColor ?? this.selectedTileColor,
horizontalTitleGap: horizontalTitleGap ?? this.horizontalTitleGap,
minVerticalPadding: minVerticalPadding ?? this.minVerticalPadding,
minLeadingWidth: minLeadingWidth ?? this.minLeadingWidth,
enableFeedback: enableFeedback ?? this.enableFeedback,
);
}
/// Linearly interpolate between ListTileThemeData objects.
static ListTileThemeData? lerp(ListTileThemeData? a, ListTileThemeData? b, double t) {
assert (t != null);
if (a == null && b == null)
return null;
return ListTileThemeData(
dense: t < 0.5 ? a?.dense : b?.dense,
shape: ShapeBorder.lerp(a?.shape, b?.shape, t),
style: t < 0.5 ? a?.style : b?.style,
selectedColor: Color.lerp(a?.selectedColor, b?.selectedColor, t),
iconColor: Color.lerp(a?.iconColor, b?.iconColor, t),
textColor: Color.lerp(a?.textColor, b?.textColor, t),
contentPadding: EdgeInsetsGeometry.lerp(a?.contentPadding, b?.contentPadding, t),
tileColor: Color.lerp(a?.tileColor, b?.tileColor, t),
selectedTileColor: Color.lerp(a?.selectedTileColor, b?.selectedTileColor, t),
horizontalTitleGap: lerpDouble(a?.horizontalTitleGap, b?.horizontalTitleGap, t),
minVerticalPadding: lerpDouble(a?.minVerticalPadding, b?.minVerticalPadding, t),
minLeadingWidth: lerpDouble(a?.minLeadingWidth, b?.minLeadingWidth, t),
enableFeedback: t < 0.5 ? a?.enableFeedback : b?.enableFeedback,
);
}
@override
int get hashCode {
return hashValues(
dense,
shape,
style,
selectedColor,
iconColor,
textColor,
contentPadding,
tileColor,
selectedTileColor,
horizontalTitleGap,
minVerticalPadding,
minLeadingWidth,
enableFeedback,
);
}
@override
bool operator ==(Object other) {
if (identical(this, other))
return true;
if (other.runtimeType != runtimeType)
return false;
return other is ListTileThemeData
&& other.dense == dense
&& other.shape == shape
&& other.style == style
&& other.selectedColor == selectedColor
&& other.iconColor == iconColor
&& other.textColor == textColor
&& other.contentPadding == contentPadding
&& other.tileColor == tileColor
&& other.selectedTileColor == selectedTileColor
&& other.horizontalTitleGap == horizontalTitleGap
&& other.minVerticalPadding == minVerticalPadding
&& other.minLeadingWidth == minLeadingWidth
&& other.enableFeedback == enableFeedback;
}
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<bool>('dense', dense, defaultValue: null));
properties.add(DiagnosticsProperty<ShapeBorder>('shape', shape, defaultValue: null));
properties.add(EnumProperty<ListTileStyle>('style', style, defaultValue: null));
properties.add(ColorProperty('selectedColor', selectedColor, defaultValue: null));
properties.add(ColorProperty('iconColor', iconColor, defaultValue: null));
properties.add(ColorProperty('textColor', textColor, defaultValue: null));
properties.add(DiagnosticsProperty<EdgeInsetsGeometry>('contentPadding', contentPadding, defaultValue: null));
properties.add(ColorProperty('tileColor', tileColor, defaultValue: null));
properties.add(ColorProperty('selectedTileColor', selectedTileColor, defaultValue: null));
properties.add(DoubleProperty('horizontalTitleGap', horizontalTitleGap, defaultValue: null));
properties.add(DoubleProperty('minVerticalPadding', minVerticalPadding, defaultValue: null));
properties.add(DoubleProperty('minLeadingWidth', minLeadingWidth, defaultValue: null));
properties.add(DiagnosticsProperty<bool>('enableFeedback', enableFeedback, defaultValue: null));
}
}
/// An inherited widget that defines color and style parameters for [ListTile]s /// Creates a list tile theme that controls the color and style parameters for
/// in this widget's subtree. /// [ListTile]s, and merges in the current list tile theme, if any.
///
/// Values specified here are used for [ListTile] properties that are not given
/// an explicit non-null value.
///
/// The [Drawer] widget specifies a tile theme for its children which sets
/// [style] to [ListTileStyle.drawer].
class ListTileTheme extends InheritedTheme {
/// Creates a list tile theme that defines the color and style parameters for
/// descendant [ListTile]s.
/// ///
/// Only the [data] parameter should be used. The other parameters are /// The [child] argument must not be null.
/// redundant (are now obsolete) and will be deprecated in a future update. static Widget merge({
const ListTileTheme({
Key? key, Key? key,
ListTileThemeData? data,
bool? dense, bool? dense,
ShapeBorder? shape, ShapeBorder? shape,
ListTileStyle? style, ListTileStyle? style,
...@@ -287,214 +79,105 @@ class ListTileTheme extends InheritedTheme { ...@@ -287,214 +79,105 @@ class ListTileTheme extends InheritedTheme {
double? minVerticalPadding, double? minVerticalPadding,
double? minLeadingWidth, double? minLeadingWidth,
required Widget child, required Widget child,
}) : assert( }) {
data == null || assert(child != null);
(shape ?? return Builder(
selectedColor ?? builder: (BuildContext context) {
iconColor ?? final ListTileTheme parent = ListTileTheme.of(context);
textColor ?? return ListTileTheme(
contentPadding ?? key: key,
tileColor ?? dense: dense ?? parent.dense,
selectedTileColor ?? shape: shape ?? parent.shape,
enableFeedback ?? style: style ?? parent.style,
horizontalTitleGap ?? selectedColor: selectedColor ?? parent.selectedColor,
minVerticalPadding ?? iconColor: iconColor ?? parent.iconColor,
minLeadingWidth) == null), textColor: textColor ?? parent.textColor,
_data = data, contentPadding: contentPadding ?? parent.contentPadding,
_dense = dense, tileColor: tileColor ?? parent.tileColor,
_shape = shape, selectedTileColor: selectedTileColor ?? parent.selectedTileColor,
_style = style, enableFeedback: enableFeedback ?? parent.enableFeedback,
_selectedColor = selectedColor, horizontalTitleGap: horizontalTitleGap ?? parent.horizontalTitleGap,
_iconColor = iconColor, minVerticalPadding: minVerticalPadding ?? parent.minVerticalPadding,
_textColor = textColor, minLeadingWidth: minLeadingWidth ?? parent.minLeadingWidth,
_contentPadding = contentPadding, child: child,
_tileColor = tileColor, );
_selectedTileColor = selectedTileColor, },
_enableFeedback = enableFeedback,
_horizontalTitleGap = horizontalTitleGap,
_minVerticalPadding = minVerticalPadding,
_minLeadingWidth = minLeadingWidth,
super(key: key, child: child);
final ListTileThemeData? _data;
final bool? _dense;
final ShapeBorder? _shape;
final ListTileStyle? _style;
final Color? _selectedColor;
final Color? _iconColor;
final Color? _textColor;
final EdgeInsetsGeometry? _contentPadding;
final Color? _tileColor;
final Color? _selectedTileColor;
final double? _horizontalTitleGap;
final double? _minVerticalPadding;
final double? _minLeadingWidth;
final bool? _enableFeedback;
/// The configuration of this theme.
ListTileThemeData get data {
return _data ?? ListTileThemeData(
shape: _shape,
style: _style,
selectedColor: _selectedColor,
iconColor: _iconColor,
textColor: _textColor,
contentPadding: _contentPadding,
tileColor: _tileColor,
selectedTileColor: _selectedTileColor,
enableFeedback: _enableFeedback,
horizontalTitleGap: _horizontalTitleGap,
minVerticalPadding: _minVerticalPadding,
minLeadingWidth: _minLeadingWidth,
); );
} }
/// Overrides the default value of [ListTile.dense]. /// If true then [ListTile]s will have the vertically dense layout.
/// final bool dense;
/// This property is obsolete: please use the [data]
/// [ListTileThemeData.dense] property instead.
bool? get dense => _data != null ? _data!.dense : _dense;
/// Overrides the default value of [ListTile.shape]. /// {@template flutter.material.ListTileTheme.shape}
/// /// If specified, [shape] defines the [ListTile]'s shape.
/// This property is obsolete: please use the [data] /// {@endtemplate}
/// [ListTileThemeData.shape] property instead. final ShapeBorder? shape;
ShapeBorder? get shape => _data != null ? _data!.shape : _shape;
/// Overrides the default value of [ListTile.style]. /// If specified, [style] defines the font used for [ListTile] titles.
/// final ListTileStyle style;
/// This property is obsolete: please use the [data]
/// [ListTileThemeData.style] property instead.
ListTileStyle? get style => _data != null ? _data!.style : _style;
/// Overrides the default value of [ListTile.selectedColor]. /// If specified, the color used for icons and text when a [ListTile] is selected.
/// final Color? selectedColor;
/// This property is obsolete: please use the [data]
/// [ListTileThemeData.selectedColor] property instead.
Color? get selectedColor => _data != null ? _data!.selectedColor : _selectedColor;
/// Overrides the default value of [ListTile.iconColor]. /// If specified, the icon color used for enabled [ListTile]s that are not selected.
/// final Color? iconColor;
/// This property is obsolete: please use the [data]
/// [ListTileThemeData.iconColor] property instead.
Color? get iconColor => _data != null ? _data!.iconColor : _iconColor;
/// Overrides the default value of [ListTile.textColor]. /// If specified, the text color used for enabled [ListTile]s that are not selected.
/// final Color? textColor;
/// This property is obsolete: please use the [data]
/// [ListTileThemeData.textColor] property instead.
Color? get textColor => _data != null ? _data!.textColor : _textColor;
/// Overrides the default value of [ListTile.contentPadding]. /// The tile's internal padding.
/// ///
/// This property is obsolete: please use the [data] /// Insets a [ListTile]'s contents: its [ListTile.leading], [ListTile.title],
/// [ListTileThemeData.contentPadding] property instead. /// [ListTile.subtitle], and [ListTile.trailing] widgets.
EdgeInsetsGeometry? get contentPadding => _data != null ? _data!.contentPadding : _contentPadding; final EdgeInsetsGeometry? contentPadding;
/// Overrides the default value of [ListTile.tileColor]. /// If specified, defines the background color for `ListTile` when
/// [ListTile.selected] is false.
/// ///
/// This property is obsolete: please use the [data] /// If [ListTile.tileColor] is provided, [tileColor] is ignored.
/// [ListTileThemeData.tileColor] property instead. final Color? tileColor;
Color? get tileColor => _data != null ? _data!.tileColor : _tileColor;
/// Overrides the default value of [ListTile.selectedTileColor]. /// If specified, defines the background color for `ListTile` when
/// [ListTile.selected] is true.
/// ///
/// This property is obsolete: please use the [data] /// If [ListTile.selectedTileColor] is provided, [selectedTileColor] is ignored.
/// [ListTileThemeData.selectedTileColor] property instead. final Color? selectedTileColor;
Color? get selectedTileColor => _data != null ? _data!.selectedTileColor : _selectedTileColor;
/// Overrides the default value of [ListTile.horizontalTitleGap]. /// The horizontal gap between the titles and the leading/trailing widgets.
/// ///
/// This property is obsolete: please use the [data] /// If specified, overrides the default value of [ListTile.horizontalTitleGap].
/// [ListTileThemeData.horizontalTitleGap] property instead. final double? horizontalTitleGap;
double? get horizontalTitleGap => _data != null ? _data!.horizontalTitleGap : _horizontalTitleGap;
/// Overrides the default value of [ListTile.minVerticalPadding]. /// The minimum padding on the top and bottom of the title and subtitle widgets.
/// ///
/// This property is obsolete: please use the [data] /// If specified, overrides the default value of [ListTile.minVerticalPadding].
/// [ListTileThemeData.minVerticalPadding] property instead. final double? minVerticalPadding;
double? get minVerticalPadding => _data != null ? _data!.minVerticalPadding : _minVerticalPadding;
/// Overrides the default value of [ListTile.minLeadingWidth]. /// The minimum width allocated for the [ListTile.leading] widget.
/// ///
/// This property is obsolete: please use the [data] /// If specified, overrides the default value of [ListTile.minLeadingWidth].
/// [ListTileThemeData.minLeadingWidth] property instead. final double? minLeadingWidth;
double? get minLeadingWidth => _data != null ? _data!.minLeadingWidth : _minLeadingWidth;
/// Overrides the default value of [ListTile.enableFeedback]. /// If specified, defines the feedback property for `ListTile`.
/// ///
/// This property is obsolete: please use the [data] /// If [ListTile.enableFeedback] is provided, [enableFeedback] is ignored.
/// [ListTileThemeData.enableFeedback] property instead. final bool? enableFeedback;
bool? get enableFeedback => _data != null ? _data!.enableFeedback : _enableFeedback;
/// The [data] property of the closest instance of this class that /// The closest instance of this class that encloses the given context.
/// encloses the given context.
///
/// If there is no enclosing [ListTileTheme] widget, then
/// [ThemeData.listTileTheme] is used (see [Theme.of]).
/// ///
/// Typical usage is as follows: /// Typical usage is as follows:
/// ///
/// ```dart /// ```dart
/// ListTileThemeData theme = ListTileTheme.of(context); /// ListTileTheme theme = ListTileTheme.of(context);
/// ``` /// ```
static ListTileThemeData of(BuildContext context) { static ListTileTheme of(BuildContext context) {
final ListTileTheme? result = context.dependOnInheritedWidgetOfExactType<ListTileTheme>(); final ListTileTheme? result = context.dependOnInheritedWidgetOfExactType<ListTileTheme>();
return result?.data ?? Theme.of(context).listTileTheme; return result ?? const ListTileTheme(child: SizedBox());
}
/// Creates a list tile theme that controls the color and style parameters for
/// [ListTile]s, and merges in the current list tile theme, if any.
///
/// The [child] argument must not be null.
static Widget merge({
Key? key,
bool? dense,
ShapeBorder? shape,
ListTileStyle? style,
Color? selectedColor,
Color? iconColor,
Color? textColor,
EdgeInsetsGeometry? contentPadding,
Color? tileColor,
Color? selectedTileColor,
bool? enableFeedback,
double? horizontalTitleGap,
double? minVerticalPadding,
double? minLeadingWidth,
required Widget child,
}) {
assert(child != null);
return Builder(
builder: (BuildContext context) {
final ListTileThemeData parent = ListTileTheme.of(context);
return ListTileTheme(
key: key,
data: ListTileThemeData(
dense: dense ?? parent.dense,
shape: shape ?? parent.shape,
style: style ?? parent.style,
selectedColor: selectedColor ?? parent.selectedColor,
iconColor: iconColor ?? parent.iconColor,
textColor: textColor ?? parent.textColor,
contentPadding: contentPadding ?? parent.contentPadding,
tileColor: tileColor ?? parent.tileColor,
selectedTileColor: selectedTileColor ?? parent.selectedTileColor,
enableFeedback: enableFeedback ?? parent.enableFeedback,
horizontalTitleGap: horizontalTitleGap ?? parent.horizontalTitleGap,
minVerticalPadding: minVerticalPadding ?? parent.minVerticalPadding,
minLeadingWidth: minLeadingWidth ?? parent.minLeadingWidth,
),
child: child,
);
},
);
} }
@override @override
Widget wrap(BuildContext context, Widget child) { Widget wrap(BuildContext context, Widget child) {
return ListTileTheme( return ListTileTheme(
data: ListTileThemeData(
dense: dense, dense: dense,
shape: shape, shape: shape,
style: style, style: style,
...@@ -508,13 +191,51 @@ class ListTileTheme extends InheritedTheme { ...@@ -508,13 +191,51 @@ class ListTileTheme extends InheritedTheme {
horizontalTitleGap: horizontalTitleGap, horizontalTitleGap: horizontalTitleGap,
minVerticalPadding: minVerticalPadding, minVerticalPadding: minVerticalPadding,
minLeadingWidth: minLeadingWidth, minLeadingWidth: minLeadingWidth,
),
child: child, child: child,
); );
} }
@override @override
bool updateShouldNotify(ListTileTheme oldWidget) => data != oldWidget.data; bool updateShouldNotify(ListTileTheme oldWidget) {
return dense != oldWidget.dense
|| shape != oldWidget.shape
|| style != oldWidget.style
|| selectedColor != oldWidget.selectedColor
|| iconColor != oldWidget.iconColor
|| textColor != oldWidget.textColor
|| contentPadding != oldWidget.contentPadding
|| tileColor != oldWidget.tileColor
|| selectedTileColor != oldWidget.selectedTileColor
|| enableFeedback != oldWidget.enableFeedback
|| horizontalTitleGap != oldWidget.horizontalTitleGap
|| minVerticalPadding != oldWidget.minVerticalPadding
|| minLeadingWidth != oldWidget.minLeadingWidth;
}
}
/// Where to place the control in widgets that use [ListTile] to position a
/// control next to a label.
///
/// See also:
///
/// * [CheckboxListTile], which combines a [ListTile] with a [Checkbox].
/// * [RadioListTile], which combines a [ListTile] with a [Radio] button.
/// * [SwitchListTile], which combines a [ListTile] with a [Switch].
/// * [ExpansionTile], which combines a [ListTile] with a button that expands
/// or collapses the tile to reveal or hide the children.
enum ListTileControlAffinity {
/// Position the control on the leading edge, and the secondary widget, if
/// any, on the trailing edge.
leading,
/// Position the control on the trailing edge, and the secondary widget, if
/// any, on the leading edge.
trailing,
/// Position the control relative to the text in the fashion that is typical
/// for the current platform, and place the secondary widget on the opposite
/// side.
platform,
} }
/// A single fixed-height row that typically contains some text as well as /// A single fixed-height row that typically contains some text as well as
...@@ -768,10 +489,6 @@ class ListTile extends StatelessWidget { ...@@ -768,10 +489,6 @@ class ListTile extends StatelessWidget {
this.dense, this.dense,
this.visualDensity, this.visualDensity,
this.shape, this.shape,
this.style,
this.selectedColor,
this.iconColor,
this.textColor,
this.contentPadding, this.contentPadding,
this.enabled = true, this.enabled = true,
this.onTap, this.onTap,
...@@ -869,62 +586,14 @@ class ListTile extends StatelessWidget { ...@@ -869,62 +586,14 @@ class ListTile extends StatelessWidget {
/// widgets within a [Theme]. /// widgets within a [Theme].
final VisualDensity? visualDensity; final VisualDensity? visualDensity;
/// {@template flutter.material.ListTile.shape} /// The tile's shape.
/// Defines the tile's [InkWell.customBorder] and [Ink.decoration] shape.
/// {@endtemplate}
/// ///
/// If this property is null then [ListTileThemeData.shape] is used. If that /// Defines the tile's [InkWell.customBorder] and [Ink.decoration] shape.
/// is also null then a rectangular [Border] will be used.
///
/// See also:
/// ///
/// * [ListTileTheme.of], which returns the nearest [ListTileTheme]'s /// If this property is null then [ListTileTheme.shape] is used.
/// [ListTileThemeData]. /// If that's null then a rectangular [Border] will be used.
final ShapeBorder? shape; final ShapeBorder? shape;
/// Defines the color used for icons and text when the list tile is selected.
///
/// If this property is null then [ListTileThemeData.selectedColor]
/// is used. If that is also null then [ColorScheme.primary] is used.
///
/// See also:
///
/// * [ListTileTheme.of], which returns the nearest [ListTileTheme]'s
/// [ListTileThemeData].
final Color? selectedColor;
/// Defines the default color for [leading] and [trailing] icons.
///
/// If this property is null then [ListTileThemeData.iconColor] is used.
///
/// See also:
///
/// * [ListTileTheme.of], which returns the nearest [ListTileTheme]'s
/// [ListTileThemeData].
final Color? iconColor;
/// Defines the default color for the [title] and [subtitle].
///
/// If this property is null then [ListTileThemeData.textColor] is used. If that
/// is also null then [ColorScheme.primary] is used.
///
/// See also:
///
/// * [ListTileTheme.of], which returns the nearest [ListTileTheme]'s
/// [ListTileThemeData].
final Color? textColor;
/// Defines the font used for the [title].
///
/// If this property is null then [ListTileThemeData.style] is used. If that
/// is also null then [ListTileStyle.list] is used.
///
/// See also:
///
/// * [ListTileTheme.of], which returns the nearest [ListTileTheme]'s
/// [ListTileThemeData].
final ListTileStyle? style;
/// The tile's internal padding. /// The tile's internal padding.
/// ///
/// Insets a [ListTile]'s contents: its [leading], [title], [subtitle], /// Insets a [ListTile]'s contents: its [leading], [title], [subtitle],
...@@ -1069,85 +738,103 @@ class ListTile extends StatelessWidget { ...@@ -1069,85 +738,103 @@ class ListTile extends StatelessWidget {
yield tile; yield tile;
} }
Color? _iconColor(ThemeData theme, ListTileThemeData tileTheme) { Color? _iconColor(ThemeData theme, ListTileTheme? tileTheme) {
if (!enabled) if (!enabled)
return theme.disabledColor; return theme.disabledColor;
if (selected) { if (selected && tileTheme?.selectedColor != null)
return selectedColor ?? tileTheme.selectedColor ?? theme.listTileTheme.selectedColor ?? theme.colorScheme.primary; return tileTheme!.selectedColor;
}
final Color? color = iconColor ?? tileTheme.iconColor ?? theme.listTileTheme.iconColor; if (!selected && tileTheme?.iconColor != null)
if (color != null) return tileTheme!.iconColor;
return color;
switch (theme.brightness) { switch (theme.brightness) {
case Brightness.light: case Brightness.light:
// For the sake of backwards compatibility, the default for unselected // For the sake of backwards compatibility, the default for unselected
// tiles is Colors.black45 rather than colorScheme.onSurface.withAlpha(0x73). // tiles is Colors.black45 rather than colorScheme.onSurface.withAlpha(0x73).
return Colors.black45; return selected ? theme.colorScheme.primary : Colors.black45;
case Brightness.dark: case Brightness.dark:
return null; // null - use current icon theme color return selected ? theme.colorScheme.primary : null; // null - use current icon theme color
} }
} }
Color? _textColor(ThemeData theme, ListTileThemeData tileTheme, Color? defaultColor) { Color? _textColor(ThemeData theme, ListTileTheme? tileTheme, Color? defaultColor) {
if (!enabled) if (!enabled)
return theme.disabledColor; return theme.disabledColor;
if (selected) { if (selected && tileTheme?.selectedColor != null)
return selectedColor ?? tileTheme.selectedColor ?? theme.listTileTheme.selectedColor ?? theme.colorScheme.primary; return tileTheme!.selectedColor;
}
if (!selected && tileTheme?.textColor != null)
return tileTheme!.textColor;
return textColor ?? tileTheme.textColor ?? theme.listTileTheme.textColor ?? defaultColor; if (selected)
return theme.colorScheme.primary;
return defaultColor;
} }
bool _isDenseLayout(ThemeData theme, ListTileThemeData tileTheme) { bool _isDenseLayout(ListTileTheme? tileTheme) {
return dense ?? tileTheme.dense ?? theme.listTileTheme.dense ?? false; return dense ?? tileTheme?.dense ?? false;
} }
TextStyle _titleTextStyle(ThemeData theme, ListTileThemeData tileTheme) { TextStyle _titleTextStyle(ThemeData theme, ListTileTheme? tileTheme) {
final TextStyle textStyle; final TextStyle style;
switch(style ?? tileTheme.style ?? theme.listTileTheme.style ?? ListTileStyle.list) { if (tileTheme != null) {
switch (tileTheme.style) {
case ListTileStyle.drawer: case ListTileStyle.drawer:
textStyle = theme.textTheme.bodyText1!; style = theme.textTheme.bodyText1!;
break; break;
case ListTileStyle.list: case ListTileStyle.list:
textStyle = theme.textTheme.subtitle1!; style = theme.textTheme.subtitle1!;
break; break;
} }
final Color? color = _textColor(theme, tileTheme, textStyle.color); } else {
return _isDenseLayout(theme, tileTheme) style = theme.textTheme.subtitle1!;
? textStyle.copyWith(fontSize: 13.0, color: color) }
: textStyle.copyWith(color: color); final Color? color = _textColor(theme, tileTheme, style.color);
return _isDenseLayout(tileTheme)
? style.copyWith(fontSize: 13.0, color: color)
: style.copyWith(color: color);
} }
TextStyle _subtitleTextStyle(ThemeData theme, ListTileThemeData tileTheme) { TextStyle _subtitleTextStyle(ThemeData theme, ListTileTheme? tileTheme) {
final TextStyle textStyle = theme.textTheme.bodyText2!; final TextStyle style = theme.textTheme.bodyText2!;
final Color? color = _textColor(theme, tileTheme, theme.textTheme.caption!.color); final Color? color = _textColor(theme, tileTheme, theme.textTheme.caption!.color);
return _isDenseLayout(theme, tileTheme) return _isDenseLayout(tileTheme)
? textStyle.copyWith(color: color, fontSize: 12.0) ? style.copyWith(color: color, fontSize: 12.0)
: textStyle.copyWith(color: color); : style.copyWith(color: color);
}
TextStyle _trailingAndLeadingTextStyle(ThemeData theme, ListTileTheme? tileTheme) {
final TextStyle style = theme.textTheme.bodyText2!;
final Color? color = _textColor(theme, tileTheme, style.color);
return style.copyWith(color: color);
}
Color _tileBackgroundColor(ListTileTheme? tileTheme) {
if (!selected) {
if (tileColor != null)
return tileColor!;
if (tileTheme?.tileColor != null)
return tileTheme!.tileColor!;
} }
TextStyle _trailingAndLeadingTextStyle(ThemeData theme, ListTileThemeData tileTheme) { if (selected) {
final TextStyle textStyle = theme.textTheme.bodyText2!; if (selectedTileColor != null)
final Color? color = _textColor(theme, tileTheme, textStyle.color); return selectedTileColor!;
return textStyle.copyWith(color: color); if (tileTheme?.selectedTileColor != null)
return tileTheme!.selectedTileColor!;
} }
Color _tileBackgroundColor(ThemeData theme, ListTileThemeData tileTheme) { return Colors.transparent;
final Color? color = selected
? selectedTileColor ?? tileTheme.selectedTileColor ?? theme.listTileTheme.selectedTileColor
: tileColor ?? tileTheme.tileColor ?? theme.listTileTheme.tileColor;
return color ?? Colors.transparent;
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
assert(debugCheckHasMaterial(context)); assert(debugCheckHasMaterial(context));
final ThemeData theme = Theme.of(context); final ThemeData theme = Theme.of(context);
final ListTileThemeData tileTheme = ListTileTheme.of(context); final ListTileTheme tileTheme = ListTileTheme.of(context);
IconThemeData? iconThemeData; IconThemeData? iconThemeData;
TextStyle? leadingAndTrailingTextStyle; TextStyle? leadingAndTrailingTextStyle;
...@@ -1229,7 +916,7 @@ class ListTile extends StatelessWidget { ...@@ -1229,7 +916,7 @@ class ListTile extends StatelessWidget {
child: Ink( child: Ink(
decoration: ShapeDecoration( decoration: ShapeDecoration(
shape: shape ?? tileTheme.shape ?? const Border(), shape: shape ?? tileTheme.shape ?? const Border(),
color: _tileBackgroundColor(theme, tileTheme), color: _tileBackgroundColor(tileTheme),
), ),
child: SafeArea( child: SafeArea(
top: false, top: false,
...@@ -1240,7 +927,7 @@ class ListTile extends StatelessWidget { ...@@ -1240,7 +927,7 @@ class ListTile extends StatelessWidget {
title: titleText, title: titleText,
subtitle: subtitleText, subtitle: subtitleText,
trailing: trailingIcon, trailing: trailingIcon,
isDense: _isDenseLayout(theme, tileTheme), isDense: _isDenseLayout(tileTheme),
visualDensity: visualDensity ?? theme.visualDensity, visualDensity: visualDensity ?? theme.visualDensity,
isThreeLine: isThreeLine, isThreeLine: isThreeLine,
textDirection: textDirection, textDirection: textDirection,
......
...@@ -236,7 +236,7 @@ class RadioListTile<T> extends StatelessWidget { ...@@ -236,7 +236,7 @@ class RadioListTile<T> extends StatelessWidget {
/// Whether this list tile is part of a vertically dense list. /// Whether this list tile is part of a vertically dense list.
/// ///
/// If this property is null then its value is based on [ListTileThemeData.dense]. /// If this property is null then its value is based on [ListTileTheme.dense].
final bool? dense; final bool? dense;
/// Whether to render icons and text in the [activeColor]. /// Whether to render icons and text in the [activeColor].
......
...@@ -291,7 +291,7 @@ class SwitchListTile extends StatelessWidget { ...@@ -291,7 +291,7 @@ class SwitchListTile extends StatelessWidget {
/// Whether this list tile is part of a vertically dense list. /// Whether this list tile is part of a vertically dense list.
/// ///
/// If this property is null then its value is based on [ListTileThemeData.dense]. /// If this property is null then its value is based on [ListTileTheme.dense].
final bool? dense; final bool? dense;
/// The tile's internal padding. /// The tile's internal padding.
...@@ -323,7 +323,7 @@ class SwitchListTile extends StatelessWidget { ...@@ -323,7 +323,7 @@ class SwitchListTile extends StatelessWidget {
/// By default, the value of `controlAffinity` is [ListTileControlAffinity.platform]. /// By default, the value of `controlAffinity` is [ListTileControlAffinity.platform].
final ListTileControlAffinity controlAffinity; final ListTileControlAffinity controlAffinity;
/// {@macro flutter.material.ListTile.shape} /// {@macro flutter.material.ListTileTheme.shape}
final ShapeBorder? shape; final ShapeBorder? shape;
/// If non-null, defines the background color when [SwitchListTile.selected] is true. /// If non-null, defines the background color when [SwitchListTile.selected] is true.
......
...@@ -28,7 +28,6 @@ import 'floating_action_button_theme.dart'; ...@@ -28,7 +28,6 @@ import 'floating_action_button_theme.dart';
import 'ink_splash.dart'; import 'ink_splash.dart';
import 'ink_well.dart' show InteractiveInkFeatureFactory; import 'ink_well.dart' show InteractiveInkFeatureFactory;
import 'input_decorator.dart'; import 'input_decorator.dart';
import 'list_tile.dart';
import 'navigation_bar_theme.dart'; import 'navigation_bar_theme.dart';
import 'navigation_rail_theme.dart'; import 'navigation_rail_theme.dart';
import 'outlined_button_theme.dart'; import 'outlined_button_theme.dart';
...@@ -341,7 +340,6 @@ class ThemeData with Diagnosticable { ...@@ -341,7 +340,6 @@ class ThemeData with Diagnosticable {
SwitchThemeData? switchTheme, SwitchThemeData? switchTheme,
ProgressIndicatorThemeData? progressIndicatorTheme, ProgressIndicatorThemeData? progressIndicatorTheme,
DrawerThemeData? drawerTheme, DrawerThemeData? drawerTheme,
ListTileThemeData? listTileTheme,
@Deprecated( @Deprecated(
'This "fix" is now enabled by default. ' 'This "fix" is now enabled by default. '
'This feature was deprecated after v2.5.0-1.0.pre.', 'This feature was deprecated after v2.5.0-1.0.pre.',
...@@ -487,7 +485,6 @@ class ThemeData with Diagnosticable { ...@@ -487,7 +485,6 @@ class ThemeData with Diagnosticable {
switchTheme ??= const SwitchThemeData(); switchTheme ??= const SwitchThemeData();
progressIndicatorTheme ??= const ProgressIndicatorThemeData(); progressIndicatorTheme ??= const ProgressIndicatorThemeData();
drawerTheme ??= const DrawerThemeData(); drawerTheme ??= const DrawerThemeData();
listTileTheme ??= const ListTileThemeData();
fixTextFieldOutlineLabel ??= true; fixTextFieldOutlineLabel ??= true;
useTextSelectionTheme ??= true; useTextSelectionTheme ??= true;
...@@ -571,7 +568,6 @@ class ThemeData with Diagnosticable { ...@@ -571,7 +568,6 @@ class ThemeData with Diagnosticable {
switchTheme: switchTheme, switchTheme: switchTheme,
progressIndicatorTheme: progressIndicatorTheme, progressIndicatorTheme: progressIndicatorTheme,
drawerTheme: drawerTheme, drawerTheme: drawerTheme,
listTileTheme: listTileTheme,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: fixTextFieldOutlineLabel,
useTextSelectionTheme: useTextSelectionTheme, useTextSelectionTheme: useTextSelectionTheme,
androidOverscrollIndicator: androidOverscrollIndicator, androidOverscrollIndicator: androidOverscrollIndicator,
...@@ -707,7 +703,6 @@ class ThemeData with Diagnosticable { ...@@ -707,7 +703,6 @@ class ThemeData with Diagnosticable {
required this.switchTheme, required this.switchTheme,
required this.progressIndicatorTheme, required this.progressIndicatorTheme,
required this.drawerTheme, required this.drawerTheme,
required this.listTileTheme,
@Deprecated( @Deprecated(
'This "fix" is now enabled by default. ' 'This "fix" is now enabled by default. '
'This feature was deprecated after v2.5.0-1.0.pre.', 'This feature was deprecated after v2.5.0-1.0.pre.',
...@@ -794,7 +789,6 @@ class ThemeData with Diagnosticable { ...@@ -794,7 +789,6 @@ class ThemeData with Diagnosticable {
assert(switchTheme != null), assert(switchTheme != null),
assert(progressIndicatorTheme != null), assert(progressIndicatorTheme != null),
assert(drawerTheme != null), assert(drawerTheme != null),
assert(listTileTheme != null),
assert(fixTextFieldOutlineLabel != null), assert(fixTextFieldOutlineLabel != null),
assert(useTextSelectionTheme != null); assert(useTextSelectionTheme != null);
...@@ -1362,9 +1356,6 @@ class ThemeData with Diagnosticable { ...@@ -1362,9 +1356,6 @@ class ThemeData with Diagnosticable {
/// A theme for customizing the appearance and layout of [Drawer] widgets. /// A theme for customizing the appearance and layout of [Drawer] widgets.
final DrawerThemeData drawerTheme; final DrawerThemeData drawerTheme;
/// A theme for customizing the appearance of [ListTile] widgets.
final ListTileThemeData listTileTheme;
/// An obsolete flag to allow apps to opt-out of a /// An obsolete flag to allow apps to opt-out of a
/// [small fix](https://github.com/flutter/flutter/issues/54028) for the Y /// [small fix](https://github.com/flutter/flutter/issues/54028) for the Y
/// coordinate of the floating label in a [TextField] [OutlineInputBorder]. /// coordinate of the floating label in a [TextField] [OutlineInputBorder].
...@@ -1526,7 +1517,6 @@ class ThemeData with Diagnosticable { ...@@ -1526,7 +1517,6 @@ class ThemeData with Diagnosticable {
SwitchThemeData? switchTheme, SwitchThemeData? switchTheme,
ProgressIndicatorThemeData? progressIndicatorTheme, ProgressIndicatorThemeData? progressIndicatorTheme,
DrawerThemeData? drawerTheme, DrawerThemeData? drawerTheme,
ListTileThemeData? listTileTheme,
@Deprecated( @Deprecated(
'This "fix" is now enabled by default. ' 'This "fix" is now enabled by default. '
'This feature was deprecated after v2.5.0-1.0.pre.', 'This feature was deprecated after v2.5.0-1.0.pre.',
...@@ -1619,7 +1609,6 @@ class ThemeData with Diagnosticable { ...@@ -1619,7 +1609,6 @@ class ThemeData with Diagnosticable {
switchTheme: switchTheme ?? this.switchTheme, switchTheme: switchTheme ?? this.switchTheme,
progressIndicatorTheme: progressIndicatorTheme ?? this.progressIndicatorTheme, progressIndicatorTheme: progressIndicatorTheme ?? this.progressIndicatorTheme,
drawerTheme: drawerTheme ?? this.drawerTheme, drawerTheme: drawerTheme ?? this.drawerTheme,
listTileTheme: listTileTheme ?? this.listTileTheme,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? this.fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? this.fixTextFieldOutlineLabel,
useTextSelectionTheme: useTextSelectionTheme ?? this.useTextSelectionTheme, useTextSelectionTheme: useTextSelectionTheme ?? this.useTextSelectionTheme,
androidOverscrollIndicator: androidOverscrollIndicator ?? this.androidOverscrollIndicator, androidOverscrollIndicator: androidOverscrollIndicator ?? this.androidOverscrollIndicator,
...@@ -1782,7 +1771,6 @@ class ThemeData with Diagnosticable { ...@@ -1782,7 +1771,6 @@ class ThemeData with Diagnosticable {
switchTheme: SwitchThemeData.lerp(a.switchTheme, b.switchTheme, t), switchTheme: SwitchThemeData.lerp(a.switchTheme, b.switchTheme, t),
progressIndicatorTheme: ProgressIndicatorThemeData.lerp(a.progressIndicatorTheme, b.progressIndicatorTheme, t)!, progressIndicatorTheme: ProgressIndicatorThemeData.lerp(a.progressIndicatorTheme, b.progressIndicatorTheme, t)!,
drawerTheme: DrawerThemeData.lerp(a.drawerTheme, b.drawerTheme, t)!, drawerTheme: DrawerThemeData.lerp(a.drawerTheme, b.drawerTheme, t)!,
listTileTheme: ListTileThemeData.lerp(a.listTileTheme, b.listTileTheme, t)!,
fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel,
useTextSelectionTheme: t < 0.5 ? a.useTextSelectionTheme : b.useTextSelectionTheme, useTextSelectionTheme: t < 0.5 ? a.useTextSelectionTheme : b.useTextSelectionTheme,
androidOverscrollIndicator: t < 0.5 ? a.androidOverscrollIndicator : b.androidOverscrollIndicator, androidOverscrollIndicator: t < 0.5 ? a.androidOverscrollIndicator : b.androidOverscrollIndicator,
...@@ -1873,7 +1861,6 @@ class ThemeData with Diagnosticable { ...@@ -1873,7 +1861,6 @@ class ThemeData with Diagnosticable {
&& other.switchTheme == switchTheme && other.switchTheme == switchTheme
&& other.progressIndicatorTheme == progressIndicatorTheme && other.progressIndicatorTheme == progressIndicatorTheme
&& other.drawerTheme == drawerTheme && other.drawerTheme == drawerTheme
&& other.listTileTheme == listTileTheme
&& other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel && other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel
&& other.useTextSelectionTheme == useTextSelectionTheme && other.useTextSelectionTheme == useTextSelectionTheme
&& other.androidOverscrollIndicator == androidOverscrollIndicator; && other.androidOverscrollIndicator == androidOverscrollIndicator;
...@@ -1963,7 +1950,6 @@ class ThemeData with Diagnosticable { ...@@ -1963,7 +1950,6 @@ class ThemeData with Diagnosticable {
switchTheme, switchTheme,
progressIndicatorTheme, progressIndicatorTheme,
drawerTheme, drawerTheme,
listTileTheme,
fixTextFieldOutlineLabel, fixTextFieldOutlineLabel,
useTextSelectionTheme, useTextSelectionTheme,
androidOverscrollIndicator, androidOverscrollIndicator,
...@@ -2051,7 +2037,6 @@ class ThemeData with Diagnosticable { ...@@ -2051,7 +2037,6 @@ class ThemeData with Diagnosticable {
properties.add(DiagnosticsProperty<SwitchThemeData>('switchTheme', switchTheme, defaultValue: defaultData.switchTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<SwitchThemeData>('switchTheme', switchTheme, defaultValue: defaultData.switchTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<ProgressIndicatorThemeData>('progressIndicatorTheme', progressIndicatorTheme, defaultValue: defaultData.progressIndicatorTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<ProgressIndicatorThemeData>('progressIndicatorTheme', progressIndicatorTheme, defaultValue: defaultData.progressIndicatorTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<DrawerThemeData>('drawerTheme', drawerTheme, defaultValue: defaultData.drawerTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<DrawerThemeData>('drawerTheme', drawerTheme, defaultValue: defaultData.drawerTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<ListTileThemeData>('listTileTheme', listTileTheme, defaultValue: defaultData.listTileTheme, level: DiagnosticLevel.debug));
properties.add(EnumProperty<AndroidOverscrollIndicator>('androidOverscrollIndicator', androidOverscrollIndicator, defaultValue: null, level: DiagnosticLevel.debug)); properties.add(EnumProperty<AndroidOverscrollIndicator>('androidOverscrollIndicator', androidOverscrollIndicator, defaultValue: null, level: DiagnosticLevel.debug));
} }
} }
......
...@@ -51,80 +51,6 @@ class TestTextState extends State<TestText> { ...@@ -51,80 +51,6 @@ class TestTextState extends State<TestText> {
} }
void main() { void main() {
test('ListTileThemeData copyWith, ==, hashCode basics', () {
expect(const ListTileThemeData(), const ListTileThemeData().copyWith());
expect(const ListTileThemeData().hashCode, const ListTileThemeData().copyWith().hashCode);
});
test('ListTileThemeData defaults', () {
const ListTileThemeData themeData = ListTileThemeData();
expect(themeData.dense, null);
expect(themeData.shape, null);
expect(themeData.style, null);
expect(themeData.selectedColor, null);
expect(themeData.iconColor, null);
expect(themeData.textColor, null);
expect(themeData.contentPadding, null);
expect(themeData.tileColor, null);
expect(themeData.selectedTileColor, null);
expect(themeData.horizontalTitleGap, null);
expect(themeData.minVerticalPadding, null);
expect(themeData.minLeadingWidth, null);
expect(themeData.enableFeedback, null);
});
testWidgets('Default ListTileThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ListTileThemeData().debugFillProperties(builder);
final List<String> description = builder.properties
.where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
.map((DiagnosticsNode node) => node.toString())
.toList();
expect(description, <String>[]);
});
testWidgets('ListTileThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ListTileThemeData(
dense: true,
shape: StadiumBorder(),
style: ListTileStyle.drawer,
selectedColor: Color(0x00000001),
iconColor: Color(0x00000002),
textColor: Color(0x00000003),
contentPadding: EdgeInsets.all(100),
tileColor: Color(0x00000004),
selectedTileColor: Color(0x00000005),
horizontalTitleGap: 200,
minVerticalPadding: 300,
minLeadingWidth: 400,
enableFeedback: true,
).debugFillProperties(builder);
final List<String> description = builder.properties
.where((DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info))
.map((DiagnosticsNode node) => node.toString())
.toList();
expect(description, <String>[
'dense: true',
'shape: StadiumBorder(BorderSide(Color(0xff000000), 0.0, BorderStyle.none))',
'style: drawer',
'selectedColor: Color(0x00000001)',
'iconColor: Color(0x00000002)',
'textColor: Color(0x00000003)',
'contentPadding: EdgeInsets.all(100.0)',
'tileColor: Color(0x00000004)',
'selectedTileColor: Color(0x00000005)',
'horizontalTitleGap: 200.0',
'minVerticalPadding: 300.0',
'minLeadingWidth: 400.0',
'enableFeedback: true'
]);
});
testWidgets('ListTile geometry (LTR)', (WidgetTester tester) async { testWidgets('ListTile geometry (LTR)', (WidgetTester tester) async {
// See https://material.io/go/design-lists // See https://material.io/go/design-lists
...@@ -365,13 +291,11 @@ void main() { ...@@ -365,13 +291,11 @@ void main() {
home: Material( home: Material(
child: Center( child: Center(
child: ListTileTheme( child: ListTileTheme(
data: ListTileThemeData(
dense: dense, dense: dense,
shape: shape, shape: shape,
selectedColor: selectedColor, selectedColor: selectedColor,
iconColor: iconColor, iconColor: iconColor,
textColor: textColor, textColor: textColor,
),
child: Builder( child: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
theme = Theme.of(context); theme = Theme.of(context);
...@@ -1796,17 +1720,15 @@ void main() { ...@@ -1796,17 +1720,15 @@ void main() {
}); });
testWidgets("ListTile respects ListTileTheme's tileColor & selectedTileColor", (WidgetTester tester) async { testWidgets("ListTile respects ListTileTheme's tileColor & selectedTileColor", (WidgetTester tester) async {
late ListTileThemeData theme; late ListTileTheme theme;
bool isSelected = false; bool isSelected = false;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Material( home: Material(
child: ListTileTheme( child: ListTileTheme(
data: ListTileThemeData(
tileColor: Colors.green.shade500, tileColor: Colors.green.shade500,
selectedTileColor: Colors.red.shade500, selectedTileColor: Colors.red.shade500,
),
child: Center( child: Center(
child: StatefulBuilder( child: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
...@@ -1844,10 +1766,8 @@ void main() { ...@@ -1844,10 +1766,8 @@ void main() {
MaterialApp( MaterialApp(
home: Material( home: Material(
child: ListTileTheme( child: ListTileTheme(
data: const ListTileThemeData(
selectedTileColor: Colors.green, selectedTileColor: Colors.green,
tileColor: Colors.red, tileColor: Colors.red,
),
child: Center( child: Center(
child: StatefulBuilder( child: StatefulBuilder(
builder: (BuildContext context, StateSetter setState) { builder: (BuildContext context, StateSetter setState) {
...@@ -1978,7 +1898,7 @@ void main() { ...@@ -1978,7 +1898,7 @@ void main() {
MaterialApp( MaterialApp(
home: Material( home: Material(
child: ListTileTheme( child: ListTileTheme(
data: const ListTileThemeData(enableFeedback: enableFeedbackTheme), enableFeedback: enableFeedbackTheme,
child: ListTile( child: ListTile(
title: const Text('Title'), title: const Text('Title'),
onTap: () {}, onTap: () {},
...@@ -2002,7 +1922,7 @@ void main() { ...@@ -2002,7 +1922,7 @@ void main() {
MaterialApp( MaterialApp(
home: Material( home: Material(
child: ListTileTheme( child: ListTileTheme(
data: const ListTileThemeData(enableFeedback: enableFeedbackTheme), enableFeedback: enableFeedbackTheme,
child: ListTile( child: ListTile(
enableFeedback: enableFeedback, enableFeedback: enableFeedback,
title: const Text('Title'), title: const Text('Title'),
...@@ -2028,7 +1948,7 @@ void main() { ...@@ -2028,7 +1948,7 @@ void main() {
textDirection: textDirection, textDirection: textDirection,
child: Material( child: Material(
child: ListTileTheme( child: ListTileTheme(
data: ListTileThemeData(horizontalTitleGap: themeHorizontalTitleGap), horizontalTitleGap: themeHorizontalTitleGap,
child: Container( child: Container(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: ListTile( child: ListTile(
...@@ -2161,7 +2081,7 @@ void main() { ...@@ -2161,7 +2081,7 @@ void main() {
textDirection: textDirection, textDirection: textDirection,
child: Material( child: Material(
child: ListTileTheme( child: ListTileTheme(
data: ListTileThemeData(minVerticalPadding: themeMinVerticalPadding), minVerticalPadding: themeMinVerticalPadding,
child: Container( child: Container(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: ListTile( child: ListTile(
...@@ -2207,7 +2127,7 @@ void main() { ...@@ -2207,7 +2127,7 @@ void main() {
textDirection: textDirection, textDirection: textDirection,
child: Material( child: Material(
child: ListTileTheme( child: ListTileTheme(
data: ListTileThemeData(minLeadingWidth: themeMinLeadingWidth), minLeadingWidth: themeMinLeadingWidth,
child: Container( child: Container(
alignment: Alignment.topLeft, alignment: Alignment.topLeft,
child: ListTile( child: ListTile(
...@@ -2321,10 +2241,8 @@ void main() { ...@@ -2321,10 +2241,8 @@ void main() {
home: Material( home: Material(
child: Center( child: Center(
child: ListTileTheme( child: ListTileTheme(
data: const ListTileThemeData(
selectedColor: selectedColor, selectedColor: selectedColor,
textColor: defaultColor, textColor: defaultColor,
),
child: Builder( child: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
theme = Theme.of(context); theme = Theme.of(context);
......
...@@ -346,7 +346,6 @@ void main() { ...@@ -346,7 +346,6 @@ void main() {
switchTheme: const SwitchThemeData(), switchTheme: const SwitchThemeData(),
progressIndicatorTheme: const ProgressIndicatorThemeData(), progressIndicatorTheme: const ProgressIndicatorThemeData(),
drawerTheme: const DrawerThemeData(), drawerTheme: const DrawerThemeData(),
listTileTheme: const ListTileThemeData(),
fixTextFieldOutlineLabel: false, fixTextFieldOutlineLabel: false,
useTextSelectionTheme: false, useTextSelectionTheme: false,
androidOverscrollIndicator: null, androidOverscrollIndicator: null,
...@@ -444,7 +443,6 @@ void main() { ...@@ -444,7 +443,6 @@ void main() {
switchTheme: const SwitchThemeData(), switchTheme: const SwitchThemeData(),
progressIndicatorTheme: const ProgressIndicatorThemeData(), progressIndicatorTheme: const ProgressIndicatorThemeData(),
drawerTheme: const DrawerThemeData(), drawerTheme: const DrawerThemeData(),
listTileTheme: const ListTileThemeData(),
fixTextFieldOutlineLabel: true, fixTextFieldOutlineLabel: true,
useTextSelectionTheme: true, useTextSelectionTheme: true,
androidOverscrollIndicator: AndroidOverscrollIndicator.stretch, androidOverscrollIndicator: AndroidOverscrollIndicator.stretch,
...@@ -523,7 +521,6 @@ void main() { ...@@ -523,7 +521,6 @@ void main() {
switchTheme: otherTheme.switchTheme, switchTheme: otherTheme.switchTheme,
progressIndicatorTheme: otherTheme.progressIndicatorTheme, progressIndicatorTheme: otherTheme.progressIndicatorTheme,
drawerTheme: otherTheme.drawerTheme, drawerTheme: otherTheme.drawerTheme,
listTileTheme: otherTheme.listTileTheme,
fixTextFieldOutlineLabel: otherTheme.fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: otherTheme.fixTextFieldOutlineLabel,
); );
...@@ -599,7 +596,6 @@ void main() { ...@@ -599,7 +596,6 @@ void main() {
expect(themeDataCopy.switchTheme, equals(otherTheme.switchTheme)); expect(themeDataCopy.switchTheme, equals(otherTheme.switchTheme));
expect(themeDataCopy.progressIndicatorTheme, equals(otherTheme.progressIndicatorTheme)); expect(themeDataCopy.progressIndicatorTheme, equals(otherTheme.progressIndicatorTheme));
expect(themeDataCopy.drawerTheme, equals(otherTheme.drawerTheme)); expect(themeDataCopy.drawerTheme, equals(otherTheme.drawerTheme));
expect(themeDataCopy.listTileTheme, equals(otherTheme.listTileTheme));
expect(themeDataCopy.fixTextFieldOutlineLabel, equals(otherTheme.fixTextFieldOutlineLabel)); expect(themeDataCopy.fixTextFieldOutlineLabel, equals(otherTheme.fixTextFieldOutlineLabel));
}); });
......
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