Unverified Commit eac17471 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Renamed ContainedButton et al. to ElevatedButton et al. (#61262)

parent aa012538
...@@ -49,8 +49,6 @@ export 'src/material/circle_avatar.dart'; ...@@ -49,8 +49,6 @@ export 'src/material/circle_avatar.dart';
export 'src/material/color_scheme.dart'; export 'src/material/color_scheme.dart';
export 'src/material/colors.dart'; export 'src/material/colors.dart';
export 'src/material/constants.dart'; export 'src/material/constants.dart';
export 'src/material/contained_button.dart';
export 'src/material/contained_button_theme.dart';
export 'src/material/data_table.dart'; export 'src/material/data_table.dart';
export 'src/material/data_table_source.dart'; export 'src/material/data_table_source.dart';
export 'src/material/debug.dart'; export 'src/material/debug.dart';
...@@ -61,6 +59,8 @@ export 'src/material/divider_theme.dart'; ...@@ -61,6 +59,8 @@ export 'src/material/divider_theme.dart';
export 'src/material/drawer.dart'; export 'src/material/drawer.dart';
export 'src/material/drawer_header.dart'; export 'src/material/drawer_header.dart';
export 'src/material/dropdown.dart'; export 'src/material/dropdown.dart';
export 'src/material/elevated_button.dart';
export 'src/material/elevated_button_theme.dart';
export 'src/material/elevation_overlay.dart'; export 'src/material/elevation_overlay.dart';
export 'src/material/expand_icon.dart'; export 'src/material/expand_icon.dart';
export 'src/material/expansion_panel.dart'; export 'src/material/expansion_panel.dart';
......
...@@ -29,12 +29,12 @@ import 'theme_data.dart'; ...@@ -29,12 +29,12 @@ import 'theme_data.dart';
/// hovered, focused, disabled, etc. /// hovered, focused, disabled, etc.
/// ///
/// These properties can override the default value for just one state or all of /// These properties can override the default value for just one state or all of
/// them. For example to create a [ContainedButton] whose background color is the /// them. For example to create a [ElevatedButton] whose background color is the
/// color scheme’s primary color with 50% opacity, but only when the button is /// color scheme’s primary color with 50% opacity, but only when the button is
/// pressed, one could write: /// pressed, one could write:
/// ///
/// ```dart /// ```dart
/// ContainedButton( /// ElevatedButton(
/// style: ButtonStyle( /// style: ButtonStyle(
/// backgroundColor: MaterialStateProperty.resolveWith<Color>( /// backgroundColor: MaterialStateProperty.resolveWith<Color>(
/// (Set<MaterialState> states) { /// (Set<MaterialState> states) {
...@@ -48,11 +48,11 @@ import 'theme_data.dart'; ...@@ -48,11 +48,11 @@ import 'theme_data.dart';
///``` ///```
/// ///
/// In this case the background color for all other button states would fallback /// In this case the background color for all other button states would fallback
/// to the ContainedButton’s default values. To unconditionally set the button's /// to the ElevatedButton’s default values. To unconditionally set the button's
/// [backgroundColor] for all states one could write: /// [backgroundColor] for all states one could write:
/// ///
/// ```dart /// ```dart
/// ContainedButton( /// ElevatedButton(
/// style: ButtonStyle( /// style: ButtonStyle(
/// backgroundColor: MaterialStateProperty.all<Color>(Colors.green), /// backgroundColor: MaterialStateProperty.all<Color>(Colors.green),
/// ), /// ),
...@@ -66,7 +66,7 @@ import 'theme_data.dart'; ...@@ -66,7 +66,7 @@ import 'theme_data.dart';
/// useful to make relatively sweeping changes based on a few initial /// useful to make relatively sweeping changes based on a few initial
/// parameters with simple values. The button styleFrom() methods /// parameters with simple values. The button styleFrom() methods
/// enable such sweeping changes. See for example: /// enable such sweeping changes. See for example:
/// [TextButton.styleFrom], [ContainedButton.styleFrom], /// [TextButton.styleFrom], [ElevatedButton.styleFrom],
/// [OutlinedButton.styleFrom]. /// [OutlinedButton.styleFrom].
/// ///
/// For example, to override the default text and icon colors for a /// For example, to override the default text and icon colors for a
...@@ -95,7 +95,7 @@ import 'theme_data.dart'; ...@@ -95,7 +95,7 @@ import 'theme_data.dart';
/// See also: /// See also:
/// ///
/// * [TextButtonTheme], the theme for [TextButton]s. /// * [TextButtonTheme], the theme for [TextButton]s.
/// * [ContainedButtonTheme], the theme for [ContainedButton]s. /// * [ElevatedButtonTheme], the theme for [ElevatedButton]s.
/// * [OutlinedButtonTheme], the theme for [OutlinedButton]s. /// * [OutlinedButtonTheme], the theme for [OutlinedButton]s.
@immutable @immutable
class ButtonStyle with Diagnosticable { class ButtonStyle with Diagnosticable {
......
...@@ -27,7 +27,7 @@ import 'theme_data.dart'; ...@@ -27,7 +27,7 @@ import 'theme_data.dart';
/// See also: /// See also:
/// ///
/// * [TextButton], a simple ButtonStyleButton without a shadow. /// * [TextButton], a simple ButtonStyleButton without a shadow.
/// * [ContainedButton], a filled ButtonStyleButton whose material elevates when pressed. /// * [ElevatedButton], a filled ButtonStyleButton whose material elevates when pressed.
/// * [OutlinedButton], similar to [TextButton], but with an outline. /// * [OutlinedButton], similar to [TextButton], but with an outline.
abstract class ButtonStyleButton extends StatefulWidget { abstract class ButtonStyleButton extends StatefulWidget {
/// Create a [ButtonStyleButton]. /// Create a [ButtonStyleButton].
...@@ -177,7 +177,7 @@ abstract class ButtonStyleButton extends StatefulWidget { ...@@ -177,7 +177,7 @@ abstract class ButtonStyleButton extends StatefulWidget {
/// ///
/// * [ButtonStyleButton], the [StatefulWidget] subclass for which this class is the [State]. /// * [ButtonStyleButton], the [StatefulWidget] subclass for which this class is the [State].
/// * [TextButton], a simple button without a shadow. /// * [TextButton], a simple button without a shadow.
/// * [ContainedButton], a filled button whose material elevates when pressed. /// * [ElevatedButton], a filled button whose material elevates when pressed.
/// * [OutlinedButton], similar to [TextButton], but with an outline. /// * [OutlinedButton], similar to [TextButton], but with an outline.
class _ButtonStyleState extends State<ButtonStyleButton> { class _ButtonStyleState extends State<ButtonStyleButton> {
final Set<MaterialState> _states = <MaterialState>{}; final Set<MaterialState> _states = <MaterialState>{};
......
...@@ -16,34 +16,34 @@ import 'button_style_button.dart'; ...@@ -16,34 +16,34 @@ import 'button_style_button.dart';
import 'color_scheme.dart'; import 'color_scheme.dart';
import 'colors.dart'; import 'colors.dart';
import 'constants.dart'; import 'constants.dart';
import 'contained_button_theme.dart'; import 'elevated_button_theme.dart';
import 'material_state.dart'; import 'material_state.dart';
import 'theme.dart'; import 'theme.dart';
import 'theme_data.dart'; import 'theme_data.dart';
/// A Material Design "contained button". /// A Material Design "elevated button".
/// ///
/// Use contained buttons to add dimension to otherwise mostly flat /// Use elevated buttons to add dimension to otherwise mostly flat
/// layouts, e.g. in long busy lists of content, or in wide /// layouts, e.g. in long busy lists of content, or in wide
/// spaces. Avoid using contained buttons on already-contained content /// spaces. Avoid using elevated buttons on already-elevated content
/// such as dialogs or cards. /// such as dialogs or cards.
/// ///
/// A contained button is a label [child] displayed on a [Material] /// An elevated button is a label [child] displayed on a [Material]
/// widget whose [Material.elevation] increases when the button is /// widget whose [Material.elevation] increases when the button is
/// pressed. The label's [Text] and [Icon] widgets are displayed in /// pressed. The label's [Text] and [Icon] widgets are displayed in
/// [style]'s [ButtonStyle.onForegroundColor] and the button's filled /// [style]'s [ButtonStyle.onForegroundColor] and the button's filled
/// background is the [ButtonStyle.backgroundColor]. /// background is the [ButtonStyle.backgroundColor].
/// ///
/// The contained button's default style is defined by /// The elevated button's default style is defined by
/// [defaultStyleOf]. The style of this contained button can be /// [defaultStyleOf]. The style of this elevated button can be
/// overridden with its [style] parameter. The style of all contained /// overridden with its [style] parameter. The style of all contained
/// buttons in a subtree can be overridden with the /// buttons in a subtree can be overridden with the
/// [ContainedButtonTheme], and the style of all of the contained /// [ElevatedButtonTheme], and the style of all of the contained
/// buttons in an app can be overridden with the [Theme]'s /// buttons in an app can be overridden with the [Theme]'s
/// [ThemeData.containedButtonTheme] property. /// [ThemeData.ElevatedButtonTheme] property.
/// ///
/// The static [styleFrom] method is a convenient way to create a /// The static [styleFrom] method is a convenient way to create a
/// contained button [ButtonStyle] from simple values. /// elevated button [ButtonStyle] from simple values.
/// ///
/// If [onPressed] and [onLongPress] callbacks are null, then the /// If [onPressed] and [onLongPress] callbacks are null, then the
/// button will be disabled. /// button will be disabled.
...@@ -53,11 +53,11 @@ import 'theme_data.dart'; ...@@ -53,11 +53,11 @@ import 'theme_data.dart';
/// * [TextButton], a simple flat button without a shadow. /// * [TextButton], a simple flat button without a shadow.
/// * [OutlinedButton], a [TextButton] with a border outline. /// * [OutlinedButton], a [TextButton] with a border outline.
/// * <https://material.io/design/components/buttons.html> /// * <https://material.io/design/components/buttons.html>
class ContainedButton extends ButtonStyleButton { class ElevatedButton extends ButtonStyleButton {
/// Create a ContainedButton. /// Create an ElevatedButton.
/// ///
/// The [autofocus] and [clipBehavior] arguments must not be null. /// The [autofocus] and [clipBehavior] arguments must not be null.
const ContainedButton({ const ElevatedButton({
Key key, Key key,
@required VoidCallback onPressed, @required VoidCallback onPressed,
VoidCallback onLongPress, VoidCallback onLongPress,
...@@ -77,14 +77,14 @@ class ContainedButton extends ButtonStyleButton { ...@@ -77,14 +77,14 @@ class ContainedButton extends ButtonStyleButton {
child: child, child: child,
); );
/// Create a contained button from a pair of widgets that serve as the button's /// Create an elevated button from a pair of widgets that serve as the button's
/// [icon] and [label]. /// [icon] and [label].
/// ///
/// The icon and label are arranged in a row and padded by 12 logical pixels /// The icon and label are arranged in a row and padded by 12 logical pixels
/// at the start, and 16 at the end, with an 8 pixel gap in between. /// at the start, and 16 at the end, with an 8 pixel gap in between.
/// ///
/// The [icon] and [label] arguments must not be null. /// The [icon] and [label] arguments must not be null.
factory ContainedButton.icon({ factory ElevatedButton.icon({
Key key, Key key,
@required VoidCallback onPressed, @required VoidCallback onPressed,
VoidCallback onLongPress, VoidCallback onLongPress,
...@@ -94,9 +94,9 @@ class ContainedButton extends ButtonStyleButton { ...@@ -94,9 +94,9 @@ class ContainedButton extends ButtonStyleButton {
Clip clipBehavior, Clip clipBehavior,
@required Widget icon, @required Widget icon,
@required Widget label, @required Widget label,
}) = _ContainedButtonWithIcon; }) = _ElevatedButtonWithIcon;
/// A static convenience method that constructs a contained button /// A static convenience method that constructs an elevated button
/// [ButtonStyle] given simple values. /// [ButtonStyle] given simple values.
/// ///
/// The [onPrimary], and [onSurface] colors are used to to create a /// The [onPrimary], and [onSurface] colors are used to to create a
...@@ -124,12 +124,12 @@ class ContainedButton extends ButtonStyleButton { ...@@ -124,12 +124,12 @@ class ContainedButton extends ButtonStyleButton {
/// a [ButtonStyle] that doesn't override anything. /// a [ButtonStyle] that doesn't override anything.
/// ///
/// For example, to override the default text and icon colors for a /// For example, to override the default text and icon colors for a
/// [ContainedButton], as well as its overlay color, with all of the /// [ElevatedButton], as well as its overlay color, with all of the
/// standard opacity adjustments for the pressed, focused, and /// standard opacity adjustments for the pressed, focused, and
/// hovered states, one could write: /// hovered states, one could write:
/// ///
/// ```dart /// ```dart
/// ContainedButton( /// ElevatedButton(
/// style: TextButton.styleFrom(primary: Colors.green), /// style: TextButton.styleFrom(primary: Colors.green),
/// ) /// )
/// ``` /// ```
...@@ -153,19 +153,19 @@ class ContainedButton extends ButtonStyleButton { ...@@ -153,19 +153,19 @@ class ContainedButton extends ButtonStyleButton {
}) { }) {
final MaterialStateProperty<Color> backgroundColor = (onSurface == null && primary == null) final MaterialStateProperty<Color> backgroundColor = (onSurface == null && primary == null)
? null ? null
: _ContainedButtonDefaultBackground(primary, onSurface); : _ElevatedButtonDefaultBackground(primary, onSurface);
final MaterialStateProperty<Color> foregroundColor = (onSurface == null && onPrimary == null) final MaterialStateProperty<Color> foregroundColor = (onSurface == null && onPrimary == null)
? null ? null
: _ContainedButtonDefaultForeground(onPrimary, onSurface); : _ElevatedButtonDefaultForeground(onPrimary, onSurface);
final MaterialStateProperty<Color> overlayColor = (onPrimary == null) final MaterialStateProperty<Color> overlayColor = (onPrimary == null)
? null ? null
: _ContainedButtonDefaultOverlay(onPrimary); : _ElevatedButtonDefaultOverlay(onPrimary);
final MaterialStateProperty<double> elevationValue = (elevation == null) final MaterialStateProperty<double> elevationValue = (elevation == null)
? null ? null
: _ContainedButtonDefaultElevation(elevation); : _ElevatedButtonDefaultElevation(elevation);
final MaterialStateProperty<MouseCursor> mouseCursor = (enabledMouseCursor == null && disabledMouseCursor == null) final MaterialStateProperty<MouseCursor> mouseCursor = (enabledMouseCursor == null && disabledMouseCursor == null)
? null ? null
: _ContainedButtonDefaultMouseCursor(enabledMouseCursor, disabledMouseCursor); : _ElevatedButtonDefaultMouseCursor(enabledMouseCursor, disabledMouseCursor);
return ButtonStyle( return ButtonStyle(
textStyle: MaterialStateProperty.all<TextStyle>(textStyle), textStyle: MaterialStateProperty.all<TextStyle>(textStyle),
...@@ -241,7 +241,7 @@ class ContainedButton extends ButtonStyleButton { ...@@ -241,7 +241,7 @@ class ContainedButton extends ButtonStyleButton {
/// * `animationDuration` - kThemeChangeDuration /// * `animationDuration` - kThemeChangeDuration
/// * `enableFeedback` - true /// * `enableFeedback` - true
/// ///
/// The default padding values for the [ContainedButton.icon] factory are slightly different: /// The default padding values for the [ElevatedButton.icon] factory are slightly different:
/// ///
/// * `padding` /// * `padding`
/// * `textScaleFactor <= 1` - start(12) end(16) /// * `textScaleFactor <= 1` - start(12) end(16)
...@@ -280,17 +280,17 @@ class ContainedButton extends ButtonStyleButton { ...@@ -280,17 +280,17 @@ class ContainedButton extends ButtonStyleButton {
); );
} }
/// Returns the [ContainedButtonThemeData.style] of the closest /// Returns the [ElevatedButtonThemeData.style] of the closest
/// [ContainedButtonTheme] ancestor. /// [ElevatedButtonTheme] ancestor.
@override @override
ButtonStyle themeStyleOf(BuildContext context) { ButtonStyle themeStyleOf(BuildContext context) {
return ContainedButtonTheme.of(context)?.style; return ElevatedButtonTheme.of(context)?.style;
} }
} }
@immutable @immutable
class _ContainedButtonDefaultBackground extends MaterialStateProperty<Color> with Diagnosticable { class _ElevatedButtonDefaultBackground extends MaterialStateProperty<Color> with Diagnosticable {
_ContainedButtonDefaultBackground(this.primary, this.onSurface); _ElevatedButtonDefaultBackground(this.primary, this.onSurface);
final Color primary; final Color primary;
final Color onSurface; final Color onSurface;
...@@ -304,8 +304,8 @@ class _ContainedButtonDefaultBackground extends MaterialStateProperty<Color> wit ...@@ -304,8 +304,8 @@ class _ContainedButtonDefaultBackground extends MaterialStateProperty<Color> wit
} }
@immutable @immutable
class _ContainedButtonDefaultForeground extends MaterialStateProperty<Color> with Diagnosticable { class _ElevatedButtonDefaultForeground extends MaterialStateProperty<Color> with Diagnosticable {
_ContainedButtonDefaultForeground(this.onPrimary, this.onSurface); _ElevatedButtonDefaultForeground(this.onPrimary, this.onSurface);
final Color onPrimary; final Color onPrimary;
final Color onSurface; final Color onSurface;
...@@ -319,8 +319,8 @@ class _ContainedButtonDefaultForeground extends MaterialStateProperty<Color> wit ...@@ -319,8 +319,8 @@ class _ContainedButtonDefaultForeground extends MaterialStateProperty<Color> wit
} }
@immutable @immutable
class _ContainedButtonDefaultOverlay extends MaterialStateProperty<Color> with Diagnosticable { class _ElevatedButtonDefaultOverlay extends MaterialStateProperty<Color> with Diagnosticable {
_ContainedButtonDefaultOverlay(this.onPrimary); _ElevatedButtonDefaultOverlay(this.onPrimary);
final Color onPrimary; final Color onPrimary;
...@@ -335,8 +335,8 @@ class _ContainedButtonDefaultOverlay extends MaterialStateProperty<Color> with D ...@@ -335,8 +335,8 @@ class _ContainedButtonDefaultOverlay extends MaterialStateProperty<Color> with D
} }
@immutable @immutable
class _ContainedButtonDefaultElevation extends MaterialStateProperty<double> with Diagnosticable { class _ElevatedButtonDefaultElevation extends MaterialStateProperty<double> with Diagnosticable {
_ContainedButtonDefaultElevation(this.elevation); _ElevatedButtonDefaultElevation(this.elevation);
final double elevation; final double elevation;
...@@ -355,8 +355,8 @@ class _ContainedButtonDefaultElevation extends MaterialStateProperty<double> wit ...@@ -355,8 +355,8 @@ class _ContainedButtonDefaultElevation extends MaterialStateProperty<double> wit
} }
@immutable @immutable
class _ContainedButtonDefaultMouseCursor extends MaterialStateProperty<MouseCursor> with Diagnosticable { class _ElevatedButtonDefaultMouseCursor extends MaterialStateProperty<MouseCursor> with Diagnosticable {
_ContainedButtonDefaultMouseCursor(this.enabledCursor, this.disabledCursor); _ElevatedButtonDefaultMouseCursor(this.enabledCursor, this.disabledCursor);
final MouseCursor enabledCursor; final MouseCursor enabledCursor;
final MouseCursor disabledCursor; final MouseCursor disabledCursor;
...@@ -369,6 +369,141 @@ class _ContainedButtonDefaultMouseCursor extends MaterialStateProperty<MouseCurs ...@@ -369,6 +369,141 @@ class _ContainedButtonDefaultMouseCursor extends MaterialStateProperty<MouseCurs
} }
} }
class _ElevatedButtonWithIcon extends ElevatedButton {
_ElevatedButtonWithIcon({
Key key,
@required VoidCallback onPressed,
VoidCallback onLongPress,
ButtonStyle style,
FocusNode focusNode,
bool autofocus,
Clip clipBehavior,
@required Widget icon,
@required Widget label,
}) : assert(icon != null),
assert(label != null),
super(
key: key,
onPressed: onPressed,
onLongPress: onLongPress,
style: style,
focusNode: focusNode,
autofocus: autofocus ?? false,
clipBehavior: clipBehavior ?? Clip.none,
child: _ElevatedButtonWithIconChild(icon: icon, label: label),
);
@override
ButtonStyle defaultStyleOf(BuildContext context) {
final EdgeInsetsGeometry scaledPadding = ButtonStyleButton.scaledPadding(
const EdgeInsetsDirectional.fromSTEB(12, 0, 16, 0),
const EdgeInsets.symmetric(horizontal: 8),
const EdgeInsetsDirectional.fromSTEB(8, 0, 4, 0),
MediaQuery.of(context, nullOk: true)?.textScaleFactor ?? 1,
);
return super.defaultStyleOf(context).copyWith(
padding: MaterialStateProperty.all<EdgeInsetsGeometry>(scaledPadding)
);
}
}
class _ElevatedButtonWithIconChild extends StatelessWidget {
const _ElevatedButtonWithIconChild({ Key key, this.label, this.icon }) : super(key: key);
final Widget label;
final Widget icon;
@override
Widget build(BuildContext context) {
final double scale = MediaQuery.of(context, nullOk: true)?.textScaleFactor ?? 1;
final double gap = scale <= 1 ? 8 : lerpDouble(8, 4, math.min(scale - 1, 1));
return Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[icon, SizedBox(width: gap), label],
);
}
}
/// Please use [ElevatedButton].
@Deprecated(
'This class was briefly released with the wrong name. The correct name is ElevatedButton. '
'This feature was deprecated after v1.20.0-2.0.pre.'
)
class ContainedButton extends ElevatedButton {
/// Please use [new ElevatedButton].
const ContainedButton({
Key key,
@required VoidCallback onPressed,
VoidCallback onLongPress,
ButtonStyle style,
FocusNode focusNode,
bool autofocus = false,
Clip clipBehavior = Clip.none,
@required Widget child,
}) : super(
key: key,
onPressed: onPressed,
onLongPress: onLongPress,
style: style,
focusNode: focusNode,
autofocus: autofocus,
clipBehavior: clipBehavior,
child: child,
);
/// Please use [new ElevatedButton.icon].
factory ContainedButton.icon({
Key key,
@required VoidCallback onPressed,
VoidCallback onLongPress,
ButtonStyle style,
FocusNode focusNode,
bool autofocus,
Clip clipBehavior,
@required Widget icon,
@required Widget label,
}) = _ContainedButtonWithIcon;
/// Please use [ElevatedButton.styleFrom].
static ButtonStyle styleFrom({
Color primary,
Color onPrimary,
Color onSurface,
Color shadowColor,
double elevation,
TextStyle textStyle,
EdgeInsetsGeometry padding,
Size minimumSize,
BorderSide side,
OutlinedBorder shape,
MouseCursor enabledMouseCursor,
MouseCursor disabledMouseCursor,
VisualDensity visualDensity,
MaterialTapTargetSize tapTargetSize,
Duration animationDuration,
bool enableFeedback,
}) {
return ElevatedButton.styleFrom(
primary: primary,
onPrimary: onPrimary,
onSurface: onSurface,
shadowColor: shadowColor,
elevation: elevation,
textStyle: textStyle,
padding: padding,
minimumSize: minimumSize,
side: side,
shape: shape,
enabledMouseCursor: enabledMouseCursor,
disabledMouseCursor: disabledMouseCursor,
visualDensity: visualDensity,
tapTargetSize: tapTargetSize,
animationDuration: animationDuration,
enableFeedback: enableFeedback,
);
}
}
class _ContainedButtonWithIcon extends ContainedButton { class _ContainedButtonWithIcon extends ContainedButton {
_ContainedButtonWithIcon({ _ContainedButtonWithIcon({
Key key, Key key,
......
...@@ -11,47 +11,47 @@ import 'button_style.dart'; ...@@ -11,47 +11,47 @@ import 'button_style.dart';
import 'theme.dart'; import 'theme.dart';
/// A [ButtonStyle] that overrides the default appearance of /// A [ButtonStyle] that overrides the default appearance of
/// [ContainedButton]s when it's used with [ContainedButtonTheme] or with the /// [ElevatedButton]s when it's used with [ElevatedButtonTheme] or with the
/// overall [Theme]'s [ThemeData.containedButtonTheme]. /// overall [Theme]'s [ThemeData.ElevatedButtonTheme].
/// ///
/// The [style]'s properties override [ContainedButton]'s default style, /// The [style]'s properties override [ElevatedButton]'s default style,
/// i.e. the [ButtonStyle] returned by [ContainedButton.defaultStyleOf]. Only /// i.e. the [ButtonStyle] returned by [ElevatedButton.defaultStyleOf]. Only
/// the style's non-null property values or resolved non-null /// the style's non-null property values or resolved non-null
/// [MaterialStateProperty] values are used. /// [MaterialStateProperty] values are used.
/// ///
/// See also: /// See also:
/// ///
/// * [ContainedButtonTheme], the theme which is configured with this class. /// * [ElevatedButtonTheme], the theme which is configured with this class.
/// * [ContainedButton.defaultStyleOf], which returns the default [ButtonStyle] /// * [ElevatedButton.defaultStyleOf], which returns the default [ButtonStyle]
/// for text buttons. /// for text buttons.
/// * [ContainedButton.styleOf], which converts simple values into a /// * [ElevatedButton.styleOf], which converts simple values into a
/// [ButtonStyle] that's consistent with [ContainedButton]'s defaults. /// [ButtonStyle] that's consistent with [ElevatedButton]'s defaults.
/// * [MaterialStateProperty.resolve], "resolve" a material state property /// * [MaterialStateProperty.resolve], "resolve" a material state property
/// to a simple value based on a set of [MaterialState]s. /// to a simple value based on a set of [MaterialState]s.
/// * [ThemeData.containedButtonTheme], which can be used to override the default /// * [ThemeData.ElevatedButtonTheme], which can be used to override the default
/// [ButtonStyle] for [ContainedButton]s below the overall [Theme]. /// [ButtonStyle] for [ElevatedButton]s below the overall [Theme].
@immutable @immutable
class ContainedButtonThemeData with Diagnosticable { class ElevatedButtonThemeData with Diagnosticable {
/// Creates a [ContainedButtonThemeData]. /// Creates an [ElevatedButtonThemeData].
/// ///
/// The [style] may be null. /// The [style] may be null.
const ContainedButtonThemeData({ this.style }); const ElevatedButtonThemeData({ this.style });
/// Overrides for [ContainedButton]'s default style. /// Overrides for [ElevatedButton]'s default style.
/// ///
/// Non-null properties or non-null resolved [MaterialStateProperty] /// Non-null properties or non-null resolved [MaterialStateProperty]
/// values override the [ButtonStyle] returned by /// values override the [ButtonStyle] returned by
/// [ContainedButton.defaultStyleOf]. /// [ElevatedButton.defaultStyleOf].
/// ///
/// If [style] is null, then this theme doesn't override anything. /// If [style] is null, then this theme doesn't override anything.
final ButtonStyle style; final ButtonStyle style;
/// Linearly interpolate between two contained button themes. /// Linearly interpolate between two elevated button themes.
static ContainedButtonThemeData lerp(ContainedButtonThemeData a, ContainedButtonThemeData b, double t) { static ElevatedButtonThemeData lerp(ElevatedButtonThemeData a, ElevatedButtonThemeData b, double t) {
assert (t != null); assert (t != null);
if (a == null && b == null) if (a == null && b == null)
return null; return null;
return ContainedButtonThemeData( return ElevatedButtonThemeData(
style: ButtonStyle.lerp(a?.style, b?.style, t), style: ButtonStyle.lerp(a?.style, b?.style, t),
); );
} }
...@@ -67,7 +67,7 @@ class ContainedButtonThemeData with Diagnosticable { ...@@ -67,7 +67,7 @@ class ContainedButtonThemeData with Diagnosticable {
return true; return true;
if (other.runtimeType != runtimeType) if (other.runtimeType != runtimeType)
return false; return false;
return other is ContainedButtonThemeData && other.style == style; return other is ElevatedButtonThemeData && other.style == style;
} }
@override @override
...@@ -77,51 +77,84 @@ class ContainedButtonThemeData with Diagnosticable { ...@@ -77,51 +77,84 @@ class ContainedButtonThemeData with Diagnosticable {
} }
} }
/// Overrides the default [ButtonStyle] of its [ContainedButton] descendants. /// Overrides the default [ButtonStyle] of its [ElevatedButton] descendants.
/// ///
/// See also: /// See also:
/// ///
/// * [ContainedButtonThemeData], which is used to configure this theme. /// * [ElevatedButtonThemeData], which is used to configure this theme.
/// * [ContainedButton.defaultStyleOf], which returns the default [ButtonStyle] /// * [ElevatedButton.defaultStyleOf], which returns the default [ButtonStyle]
/// for text buttons. /// for elevated buttons.
/// * [ContainedButton.styleOf], which converts simple values into a /// * [ElevatedButton.styleOf], which converts simple values into a
/// [ButtonStyle] that's consistent with [ContainedButton]'s defaults. /// [ButtonStyle] that's consistent with [ElevatedButton]'s defaults.
/// * [ThemeData.containedButtonTheme], which can be used to override the default /// * [ThemeData.ElevatedButtonTheme], which can be used to override the default
/// [ButtonStyle] for [ContainedButton]s below the overall [Theme]. /// [ButtonStyle] for [ElevatedButton]s below the overall [Theme].
class ContainedButtonTheme extends InheritedTheme { class ElevatedButtonTheme extends InheritedTheme {
/// Create a [ContainedButtonTheme]. /// Create a [ElevatedButtonTheme].
/// ///
/// The [data] parameter must not be null. /// The [data] parameter must not be null.
const ContainedButtonTheme({ const ElevatedButtonTheme({
Key key, Key key,
@required this.data, @required this.data,
Widget child, Widget child,
}) : assert(data != null), super(key: key, child: child); }) : assert(data != null), super(key: key, child: child);
/// The configuration of this theme. /// The configuration of this theme.
final ContainedButtonThemeData data; final ElevatedButtonThemeData data;
/// The closest instance of this class that encloses the given context. /// The closest instance of this class that encloses the given context.
/// ///
/// If there is no enclosing [ContainedButtonsTheme] widget, then /// If there is no enclosing [ElevatedButtonsTheme] widget, then
/// [ThemeData.containedButtonTheme] is used. /// [ThemeData.ElevatedButtonTheme] is used.
/// ///
/// Typical usage is as follows: /// Typical usage is as follows:
/// ///
/// ```dart /// ```dart
/// ContainedButtonTheme theme = ContainedButtonTheme.of(context); /// ElevatedButtonTheme theme = ElevatedButtonTheme.of(context);
/// ``` /// ```
static ContainedButtonThemeData of(BuildContext context) { static ElevatedButtonThemeData of(BuildContext context) {
final ContainedButtonTheme buttonTheme = context.dependOnInheritedWidgetOfExactType<ContainedButtonTheme>(); final ElevatedButtonTheme buttonTheme = context.dependOnInheritedWidgetOfExactType<ElevatedButtonTheme>();
return buttonTheme?.data ?? Theme.of(context).containedButtonTheme; return buttonTheme?.data ?? Theme.of(context).elevatedButtonTheme;
} }
@override @override
Widget wrap(BuildContext context, Widget child) { Widget wrap(BuildContext context, Widget child) {
final ContainedButtonTheme ancestorTheme = context.findAncestorWidgetOfExactType<ContainedButtonTheme>(); final ElevatedButtonTheme ancestorTheme = context.findAncestorWidgetOfExactType<ElevatedButtonTheme>();
return identical(this, ancestorTheme) ? child : ContainedButtonTheme(data: data, child: child); return identical(this, ancestorTheme) ? child : ElevatedButtonTheme(data: data, child: child);
} }
@override @override
bool updateShouldNotify(ContainedButtonTheme oldWidget) => data != oldWidget.data; bool updateShouldNotify(ElevatedButtonTheme oldWidget) => data != oldWidget.data;
}
/// Please use [ElevatedButtonTheme].
@Deprecated(
'This class was briefly released with the wrong name. '
'The correct name is ElevatedButtonThemeData. '
'This feature was deprecated after v1.20.0-2.0.pre.'
)
@immutable
class ContainedButtonThemeData extends ElevatedButtonThemeData {
/// Please use [new ElevatedButtonTheme].
const ContainedButtonThemeData({ ButtonStyle style }) : super(style: style);
/// Please use [ElevatedButtonTheme.lerp()].
static ContainedButtonThemeData lerp(ContainedButtonThemeData a, ContainedButtonThemeData b, double t) {
return ElevatedButtonThemeData.lerp(a, b, t) as ContainedButtonThemeData;
}
}
/// Please use [ElevatedButtonThemeData].
@Deprecated(
'This class was briefly released with the wrong name. '
'The correct name is ElevatedButtonTheme. '
'This feature was deprecated after v1.20.0-2.0.pre.'
)
class ContainedButtonTheme extends ElevatedButtonTheme {
/// Please use [new ElevatedButtonThemeData].
const ContainedButtonTheme({
Key key,
@required ContainedButtonThemeData data,
Widget child,
}) : assert(data != null), super(key: key, data: data, child: child);
} }
...@@ -46,7 +46,7 @@ import 'theme_data.dart'; ...@@ -46,7 +46,7 @@ import 'theme_data.dart';
/// ///
/// See also: /// See also:
/// ///
/// * [ContainedButton], a filled material design button with a shadow. /// * [ElevatedButton], a filled material design button with a shadow.
/// * [TextButton], a material design button without a shadow. /// * [TextButton], a material design button without a shadow.
/// * <https://material.io/design/components/buttons.html> /// * <https://material.io/design/components/buttons.html>
class OutlinedButton extends ButtonStyleButton { class OutlinedButton extends ButtonStyleButton {
......
...@@ -23,7 +23,7 @@ import 'theme.dart'; ...@@ -23,7 +23,7 @@ import 'theme.dart';
/// ///
/// * [OutlinedButtonTheme], the theme which is configured with this class. /// * [OutlinedButtonTheme], the theme which is configured with this class.
/// * [OutlinedButton.defaultStyleOf], which returns the default [ButtonStyle] /// * [OutlinedButton.defaultStyleOf], which returns the default [ButtonStyle]
/// for text buttons. /// for outlined buttons.
/// * [OutlinedButton.styleOf], which converts simple values into a /// * [OutlinedButton.styleOf], which converts simple values into a
/// [ButtonStyle] that's consistent with [OutlinedButton]'s defaults. /// [ButtonStyle] that's consistent with [OutlinedButton]'s defaults.
/// * [MaterialStateProperty.resolve], "resolve" a material state property /// * [MaterialStateProperty.resolve], "resolve" a material state property
...@@ -83,7 +83,7 @@ class OutlinedButtonThemeData with Diagnosticable { ...@@ -83,7 +83,7 @@ class OutlinedButtonThemeData with Diagnosticable {
/// ///
/// * [OutlinedButtonThemeData], which is used to configure this theme. /// * [OutlinedButtonThemeData], which is used to configure this theme.
/// * [OutlinedButton.defaultStyleOf], which returns the default [ButtonStyle] /// * [OutlinedButton.defaultStyleOf], which returns the default [ButtonStyle]
/// for text buttons. /// for outlined buttons.
/// * [OutlinedButton.styleOf], which converts simple values into a /// * [OutlinedButton.styleOf], which converts simple values into a
/// [ButtonStyle] that's consistent with [OutlinedButton]'s defaults. /// [ButtonStyle] that's consistent with [OutlinedButton]'s defaults.
/// * [ThemeData.outlinedButtonTheme], which can be used to override the default /// * [ThemeData.outlinedButtonTheme], which can be used to override the default
......
...@@ -54,7 +54,7 @@ import 'theme_data.dart'; ...@@ -54,7 +54,7 @@ import 'theme_data.dart';
/// See also: /// See also:
/// ///
/// * [OutlinedButton], a [TextButton] with a border outline. /// * [OutlinedButton], a [TextButton] with a border outline.
/// * [ContainedButton], a filled button whose material elevates when pressed. /// * [ElevatedButton], a filled button whose material elevates when pressed.
/// * <https://material.io/design/components/buttons.html> /// * <https://material.io/design/components/buttons.html>
class TextButton extends ButtonStyleButton { class TextButton extends ButtonStyleButton {
/// Create a TextButton. /// Create a TextButton.
......
...@@ -22,9 +22,9 @@ import 'card_theme.dart'; ...@@ -22,9 +22,9 @@ import 'card_theme.dart';
import 'chip_theme.dart'; import 'chip_theme.dart';
import 'color_scheme.dart'; import 'color_scheme.dart';
import 'colors.dart'; import 'colors.dart';
import 'contained_button_theme.dart';
import 'dialog_theme.dart'; import 'dialog_theme.dart';
import 'divider_theme.dart'; import 'divider_theme.dart';
import 'elevated_button_theme.dart';
import 'floating_action_button_theme.dart'; 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;
...@@ -276,7 +276,7 @@ class ThemeData with Diagnosticable { ...@@ -276,7 +276,7 @@ class ThemeData with Diagnosticable {
BottomNavigationBarThemeData bottomNavigationBarTheme, BottomNavigationBarThemeData bottomNavigationBarTheme,
TimePickerThemeData timePickerTheme, TimePickerThemeData timePickerTheme,
TextButtonThemeData textButtonTheme, TextButtonThemeData textButtonTheme,
ContainedButtonThemeData containedButtonTheme, ElevatedButtonThemeData elevatedButtonTheme,
OutlinedButtonThemeData outlinedButtonTheme, OutlinedButtonThemeData outlinedButtonTheme,
bool fixTextFieldOutlineLabel, bool fixTextFieldOutlineLabel,
}) { }) {
...@@ -392,7 +392,7 @@ class ThemeData with Diagnosticable { ...@@ -392,7 +392,7 @@ class ThemeData with Diagnosticable {
bottomNavigationBarTheme ??= const BottomNavigationBarThemeData(); bottomNavigationBarTheme ??= const BottomNavigationBarThemeData();
timePickerTheme ??= const TimePickerThemeData(); timePickerTheme ??= const TimePickerThemeData();
textButtonTheme ??= const TextButtonThemeData(); textButtonTheme ??= const TextButtonThemeData();
containedButtonTheme ??= const ContainedButtonThemeData(); elevatedButtonTheme ??= const ElevatedButtonThemeData();
outlinedButtonTheme ??= const OutlinedButtonThemeData(); outlinedButtonTheme ??= const OutlinedButtonThemeData();
fixTextFieldOutlineLabel ??= false; fixTextFieldOutlineLabel ??= false;
...@@ -464,7 +464,7 @@ class ThemeData with Diagnosticable { ...@@ -464,7 +464,7 @@ class ThemeData with Diagnosticable {
bottomNavigationBarTheme: bottomNavigationBarTheme, bottomNavigationBarTheme: bottomNavigationBarTheme,
timePickerTheme: timePickerTheme, timePickerTheme: timePickerTheme,
textButtonTheme: textButtonTheme, textButtonTheme: textButtonTheme,
containedButtonTheme: containedButtonTheme, elevatedButtonTheme: elevatedButtonTheme,
outlinedButtonTheme: outlinedButtonTheme, outlinedButtonTheme: outlinedButtonTheme,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: fixTextFieldOutlineLabel,
); );
...@@ -548,7 +548,7 @@ class ThemeData with Diagnosticable { ...@@ -548,7 +548,7 @@ class ThemeData with Diagnosticable {
@required this.bottomNavigationBarTheme, @required this.bottomNavigationBarTheme,
@required this.timePickerTheme, @required this.timePickerTheme,
@required this.textButtonTheme, @required this.textButtonTheme,
@required this.containedButtonTheme, @required this.elevatedButtonTheme,
@required this.outlinedButtonTheme, @required this.outlinedButtonTheme,
@required this.fixTextFieldOutlineLabel, @required this.fixTextFieldOutlineLabel,
}) : assert(visualDensity != null), }) : assert(visualDensity != null),
...@@ -615,7 +615,7 @@ class ThemeData with Diagnosticable { ...@@ -615,7 +615,7 @@ class ThemeData with Diagnosticable {
assert(bottomNavigationBarTheme != null), assert(bottomNavigationBarTheme != null),
assert(timePickerTheme != null), assert(timePickerTheme != null),
assert(textButtonTheme != null), assert(textButtonTheme != null),
assert(containedButtonTheme != null), assert(elevatedButtonTheme != null),
assert(outlinedButtonTheme != null), assert(outlinedButtonTheme != null),
assert(fixTextFieldOutlineLabel != null); assert(fixTextFieldOutlineLabel != null);
...@@ -1086,8 +1086,8 @@ class ThemeData with Diagnosticable { ...@@ -1086,8 +1086,8 @@ class ThemeData with Diagnosticable {
final TextButtonThemeData textButtonTheme; final TextButtonThemeData textButtonTheme;
/// A theme for customizing the appearance and internal layout of /// A theme for customizing the appearance and internal layout of
/// [ContainedButton]s /// [ElevatedButton]s
final ContainedButtonThemeData containedButtonTheme; final ElevatedButtonThemeData elevatedButtonTheme;
/// A theme for customizing the appearance and internal layout of /// A theme for customizing the appearance and internal layout of
/// [OutlinedButton]s. /// [OutlinedButton]s.
...@@ -1177,7 +1177,7 @@ class ThemeData with Diagnosticable { ...@@ -1177,7 +1177,7 @@ class ThemeData with Diagnosticable {
BottomNavigationBarThemeData bottomNavigationBarTheme, BottomNavigationBarThemeData bottomNavigationBarTheme,
TimePickerThemeData timePickerTheme, TimePickerThemeData timePickerTheme,
TextButtonThemeData textButtonTheme, TextButtonThemeData textButtonTheme,
ContainedButtonThemeData containedButtonTheme, ElevatedButtonThemeData elevatedButtonTheme,
OutlinedButtonThemeData outlinedButtonTheme, OutlinedButtonThemeData outlinedButtonTheme,
bool fixTextFieldOutlineLabel, bool fixTextFieldOutlineLabel,
}) { }) {
...@@ -1250,7 +1250,7 @@ class ThemeData with Diagnosticable { ...@@ -1250,7 +1250,7 @@ class ThemeData with Diagnosticable {
bottomNavigationBarTheme: bottomNavigationBarTheme ?? this.bottomNavigationBarTheme, bottomNavigationBarTheme: bottomNavigationBarTheme ?? this.bottomNavigationBarTheme,
timePickerTheme: timePickerTheme ?? this.timePickerTheme, timePickerTheme: timePickerTheme ?? this.timePickerTheme,
textButtonTheme: textButtonTheme ?? this.textButtonTheme, textButtonTheme: textButtonTheme ?? this.textButtonTheme,
containedButtonTheme: containedButtonTheme ?? this.containedButtonTheme, elevatedButtonTheme: elevatedButtonTheme ?? this.elevatedButtonTheme,
outlinedButtonTheme: outlinedButtonTheme ?? this.outlinedButtonTheme, outlinedButtonTheme: outlinedButtonTheme ?? this.outlinedButtonTheme,
fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? this.fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: fixTextFieldOutlineLabel ?? this.fixTextFieldOutlineLabel,
); );
...@@ -1401,7 +1401,7 @@ class ThemeData with Diagnosticable { ...@@ -1401,7 +1401,7 @@ class ThemeData with Diagnosticable {
bottomNavigationBarTheme: BottomNavigationBarThemeData.lerp(a.bottomNavigationBarTheme, b.bottomNavigationBarTheme, t), bottomNavigationBarTheme: BottomNavigationBarThemeData.lerp(a.bottomNavigationBarTheme, b.bottomNavigationBarTheme, t),
timePickerTheme: TimePickerThemeData.lerp(a.timePickerTheme, b.timePickerTheme, t), timePickerTheme: TimePickerThemeData.lerp(a.timePickerTheme, b.timePickerTheme, t),
textButtonTheme: TextButtonThemeData.lerp(a.textButtonTheme, b.textButtonTheme, t), textButtonTheme: TextButtonThemeData.lerp(a.textButtonTheme, b.textButtonTheme, t),
containedButtonTheme: ContainedButtonThemeData.lerp(a.containedButtonTheme, b.containedButtonTheme, t), elevatedButtonTheme: ElevatedButtonThemeData.lerp(a.elevatedButtonTheme, b.elevatedButtonTheme, t),
outlinedButtonTheme: OutlinedButtonThemeData.lerp(a.outlinedButtonTheme, b.outlinedButtonTheme, t), outlinedButtonTheme: OutlinedButtonThemeData.lerp(a.outlinedButtonTheme, b.outlinedButtonTheme, t),
fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: t < 0.5 ? a.fixTextFieldOutlineLabel : b.fixTextFieldOutlineLabel,
); );
...@@ -1480,7 +1480,7 @@ class ThemeData with Diagnosticable { ...@@ -1480,7 +1480,7 @@ class ThemeData with Diagnosticable {
&& other.bottomNavigationBarTheme == bottomNavigationBarTheme && other.bottomNavigationBarTheme == bottomNavigationBarTheme
&& other.timePickerTheme == timePickerTheme && other.timePickerTheme == timePickerTheme
&& other.textButtonTheme == textButtonTheme && other.textButtonTheme == textButtonTheme
&& other.containedButtonTheme == containedButtonTheme && other.elevatedButtonTheme == elevatedButtonTheme
&& other.outlinedButtonTheme == outlinedButtonTheme && other.outlinedButtonTheme == outlinedButtonTheme
&& other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel; && other.fixTextFieldOutlineLabel == fixTextFieldOutlineLabel;
} }
...@@ -1558,7 +1558,7 @@ class ThemeData with Diagnosticable { ...@@ -1558,7 +1558,7 @@ class ThemeData with Diagnosticable {
bottomNavigationBarTheme, bottomNavigationBarTheme,
timePickerTheme, timePickerTheme,
textButtonTheme, textButtonTheme,
containedButtonTheme, elevatedButtonTheme,
outlinedButtonTheme, outlinedButtonTheme,
fixTextFieldOutlineLabel, fixTextFieldOutlineLabel,
]; ];
...@@ -1633,7 +1633,7 @@ class ThemeData with Diagnosticable { ...@@ -1633,7 +1633,7 @@ class ThemeData with Diagnosticable {
properties.add(DiagnosticsProperty<TimePickerThemeData>('timePickerTheme', timePickerTheme, defaultValue: defaultData.timePickerTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<TimePickerThemeData>('timePickerTheme', timePickerTheme, defaultValue: defaultData.timePickerTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<BottomNavigationBarThemeData>('bottomNavigationBarTheme', bottomNavigationBarTheme, defaultValue: defaultData.bottomNavigationBarTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<BottomNavigationBarThemeData>('bottomNavigationBarTheme', bottomNavigationBarTheme, defaultValue: defaultData.bottomNavigationBarTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<TextButtonThemeData>('textButtonTheme', textButtonTheme, defaultValue: defaultData.textButtonTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<TextButtonThemeData>('textButtonTheme', textButtonTheme, defaultValue: defaultData.textButtonTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<ContainedButtonThemeData>('containedButtonTheme', containedButtonTheme, defaultValue: defaultData.containedButtonTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<ElevatedButtonThemeData>('elevatedButtonTheme', elevatedButtonTheme, defaultValue: defaultData.elevatedButtonTheme, level: DiagnosticLevel.debug));
properties.add(DiagnosticsProperty<OutlinedButtonThemeData>('outlinedButtonTheme', outlinedButtonTheme, defaultValue: defaultData.outlinedButtonTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty<OutlinedButtonThemeData>('outlinedButtonTheme', outlinedButtonTheme, defaultValue: defaultData.outlinedButtonTheme, level: DiagnosticLevel.debug));
} }
} }
......
...@@ -13,20 +13,20 @@ import '../rendering/mock_canvas.dart'; ...@@ -13,20 +13,20 @@ import '../rendering/mock_canvas.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
void main() { void main() {
testWidgets('ContainedButton defaults', (WidgetTester tester) async { testWidgets('ElevatedButton defaults', (WidgetTester tester) async {
final Finder rawButtonMaterial = find.descendant( final Finder rawButtonMaterial = find.descendant(
of: find.byType(ContainedButton), of: find.byType(ElevatedButton),
matching: find.byType(Material), matching: find.byType(Material),
); );
const ColorScheme colorScheme = ColorScheme.light(); const ColorScheme colorScheme = ColorScheme.light();
// Enabled ContainedButton // Enabled ElevatedButton
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData.from(colorScheme: colorScheme), theme: ThemeData.from(colorScheme: colorScheme),
home: Center( home: Center(
child: ContainedButton( child: ElevatedButton(
onPressed: () { }, onPressed: () { },
child: const Text('button'), child: const Text('button'),
), ),
...@@ -49,7 +49,7 @@ void main() { ...@@ -49,7 +49,7 @@ void main() {
expect(material.textStyle.fontWeight, FontWeight.w500); expect(material.textStyle.fontWeight, FontWeight.w500);
expect(material.type, MaterialType.button); expect(material.type, MaterialType.button);
final Offset center = tester.getCenter(find.byType(ContainedButton)); final Offset center = tester.getCenter(find.byType(ElevatedButton));
await tester.startGesture(center); await tester.startGesture(center);
await tester.pumpAndSettle(); await tester.pumpAndSettle();
...@@ -69,12 +69,12 @@ void main() { ...@@ -69,12 +69,12 @@ void main() {
expect(material.textStyle.fontWeight, FontWeight.w500); expect(material.textStyle.fontWeight, FontWeight.w500);
expect(material.type, MaterialType.button); expect(material.type, MaterialType.button);
// Disabled ContainedButton // Disabled ElevatedButton
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData.from(colorScheme: colorScheme), theme: ThemeData.from(colorScheme: colorScheme),
home: const Center( home: const Center(
child: ContainedButton( child: ElevatedButton(
onPressed: null, onPressed: null,
child: Text('button'), child: Text('button'),
), ),
...@@ -98,7 +98,7 @@ void main() { ...@@ -98,7 +98,7 @@ void main() {
expect(material.type, MaterialType.button); expect(material.type, MaterialType.button);
}); });
testWidgets('Default ContainedButton meets a11y contrast guidelines', (WidgetTester tester) async { testWidgets('Default ElevatedButton meets a11y contrast guidelines', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -106,8 +106,8 @@ void main() { ...@@ -106,8 +106,8 @@ void main() {
theme: ThemeData.from(colorScheme: const ColorScheme.light()), theme: ThemeData.from(colorScheme: const ColorScheme.light()),
home: Scaffold( home: Scaffold(
body: Center( body: Center(
child: ContainedButton( child: ElevatedButton(
child: const Text('ContainedButton'), child: const Text('ElevatedButton'),
onPressed: () { }, onPressed: () { },
focusNode: focusNode, focusNode: focusNode,
), ),
...@@ -125,7 +125,7 @@ void main() { ...@@ -125,7 +125,7 @@ void main() {
await expectLater(tester, meetsGuideline(textContrastGuideline)); await expectLater(tester, meetsGuideline(textContrastGuideline));
// Hovered. // Hovered.
final Offset center = tester.getCenter(find.byType(ContainedButton)); final Offset center = tester.getCenter(find.byType(ElevatedButton));
final TestGesture gesture = await tester.createGesture( final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
...@@ -140,7 +140,7 @@ void main() { ...@@ -140,7 +140,7 @@ void main() {
); );
testWidgets('ContainedButton uses stateful color for text color in different states', (WidgetTester tester) async { testWidgets('ElevatedButton uses stateful color for text color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
const Color pressedColor = Color(0x00000001); const Color pressedColor = Color(0x00000001);
...@@ -165,16 +165,16 @@ void main() { ...@@ -165,16 +165,16 @@ void main() {
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
body: Center( body: Center(
child: ContainedButtonTheme( child: ElevatedButtonTheme(
data: ContainedButtonThemeData( data: ElevatedButtonThemeData(
style: ButtonStyle( style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color>(getTextColor), foregroundColor: MaterialStateProperty.resolveWith<Color>(getTextColor),
), ),
), ),
child: Builder( child: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return ContainedButton( return ElevatedButton(
child: const Text('ContainedButton'), child: const Text('ElevatedButton'),
onPressed: () {}, onPressed: () {},
focusNode: focusNode, focusNode: focusNode,
); );
...@@ -187,7 +187,7 @@ void main() { ...@@ -187,7 +187,7 @@ void main() {
); );
Color textColor() { Color textColor() {
return tester.renderObject<RenderParagraph>(find.text('ContainedButton')).text.style.color; return tester.renderObject<RenderParagraph>(find.text('ElevatedButton')).text.style.color;
} }
// Default, not disabled. // Default, not disabled.
...@@ -199,7 +199,7 @@ void main() { ...@@ -199,7 +199,7 @@ void main() {
expect(textColor(), focusedColor); expect(textColor(), focusedColor);
// Hovered. // Hovered.
final Offset center = tester.getCenter(find.byType(ContainedButton)); final Offset center = tester.getCenter(find.byType(ElevatedButton));
final TestGesture gesture = await tester.createGesture( final TestGesture gesture = await tester.createGesture(
kind: PointerDeviceKind.mouse, kind: PointerDeviceKind.mouse,
); );
...@@ -217,7 +217,7 @@ void main() { ...@@ -217,7 +217,7 @@ void main() {
}); });
testWidgets('ContainedButton uses stateful color for icon color in different states', (WidgetTester tester) async { testWidgets('ElevatedButton uses stateful color for icon color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
final Key buttonKey = UniqueKey(); final Key buttonKey = UniqueKey();
...@@ -243,18 +243,18 @@ void main() { ...@@ -243,18 +243,18 @@ void main() {
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
body: Center( body: Center(
child: ContainedButtonTheme( child: ElevatedButtonTheme(
data: ContainedButtonThemeData( data: ElevatedButtonThemeData(
style: ButtonStyle( style: ButtonStyle(
foregroundColor: MaterialStateProperty.resolveWith<Color>(getTextColor), foregroundColor: MaterialStateProperty.resolveWith<Color>(getTextColor),
), ),
), ),
child: Builder( child: Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return ContainedButton.icon( return ElevatedButton.icon(
key: buttonKey, key: buttonKey,
icon: const Icon(Icons.add), icon: const Icon(Icons.add),
label: const Text('ContainedButton'), label: const Text('ElevatedButton'),
onPressed: () {}, onPressed: () {},
focusNode: focusNode, focusNode: focusNode,
); );
...@@ -293,14 +293,14 @@ void main() { ...@@ -293,14 +293,14 @@ void main() {
expect(iconColor(), pressedColor); expect(iconColor(), pressedColor);
}); });
testWidgets('ContainedButton onPressed and onLongPress callbacks are correctly called when non-null', (WidgetTester tester) async { testWidgets('ElevatedButton onPressed and onLongPress callbacks are correctly called when non-null', (WidgetTester tester) async {
bool wasPressed; bool wasPressed;
Finder containedButton; Finder elevatedButton;
Widget buildFrame({ VoidCallback onPressed, VoidCallback onLongPress }) { Widget buildFrame({ VoidCallback onPressed, VoidCallback onLongPress }) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: ContainedButton( child: ElevatedButton(
child: const Text('button'), child: const Text('button'),
onPressed: onPressed, onPressed: onPressed,
onLongPress: onLongPress, onLongPress: onLongPress,
...@@ -313,9 +313,9 @@ void main() { ...@@ -313,9 +313,9 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
buildFrame(onPressed: () { wasPressed = true; }, onLongPress: null), buildFrame(onPressed: () { wasPressed = true; }, onLongPress: null),
); );
containedButton = find.byType(ContainedButton); elevatedButton = find.byType(ElevatedButton);
expect(tester.widget<ContainedButton>(containedButton).enabled, true); expect(tester.widget<ElevatedButton>(elevatedButton).enabled, true);
await tester.tap(containedButton); await tester.tap(elevatedButton);
expect(wasPressed, true); expect(wasPressed, true);
// onPressed null, onLongPress not null. // onPressed null, onLongPress not null.
...@@ -323,27 +323,27 @@ void main() { ...@@ -323,27 +323,27 @@ void main() {
await tester.pumpWidget( await tester.pumpWidget(
buildFrame(onPressed: null, onLongPress: () { wasPressed = true; }), buildFrame(onPressed: null, onLongPress: () { wasPressed = true; }),
); );
containedButton = find.byType(ContainedButton); elevatedButton = find.byType(ElevatedButton);
expect(tester.widget<ContainedButton>(containedButton).enabled, true); expect(tester.widget<ElevatedButton>(elevatedButton).enabled, true);
await tester.longPress(containedButton); await tester.longPress(elevatedButton);
expect(wasPressed, true); expect(wasPressed, true);
// onPressed null, onLongPress null. // onPressed null, onLongPress null.
await tester.pumpWidget( await tester.pumpWidget(
buildFrame(onPressed: null, onLongPress: null), buildFrame(onPressed: null, onLongPress: null),
); );
containedButton = find.byType(ContainedButton); elevatedButton = find.byType(ElevatedButton);
expect(tester.widget<ContainedButton>(containedButton).enabled, false); expect(tester.widget<ElevatedButton>(elevatedButton).enabled, false);
}); });
testWidgets('ContainedButton onPressed and onLongPress callbacks are distinctly recognized', (WidgetTester tester) async { testWidgets('ElevatedButton onPressed and onLongPress callbacks are distinctly recognized', (WidgetTester tester) async {
bool didPressButton = false; bool didPressButton = false;
bool didLongPressButton = false; bool didLongPressButton = false;
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: ContainedButton( child: ElevatedButton(
onPressed: () { onPressed: () {
didPressButton = true; didPressButton = true;
}, },
...@@ -355,25 +355,25 @@ void main() { ...@@ -355,25 +355,25 @@ void main() {
), ),
); );
final Finder containedButton = find.byType(ContainedButton); final Finder elevatedButton = find.byType(ElevatedButton);
expect(tester.widget<ContainedButton>(containedButton).enabled, true); expect(tester.widget<ElevatedButton>(elevatedButton).enabled, true);
expect(didPressButton, isFalse); expect(didPressButton, isFalse);
await tester.tap(containedButton); await tester.tap(elevatedButton);
expect(didPressButton, isTrue); expect(didPressButton, isTrue);
expect(didLongPressButton, isFalse); expect(didLongPressButton, isFalse);
await tester.longPress(containedButton); await tester.longPress(elevatedButton);
expect(didLongPressButton, isTrue); expect(didLongPressButton, isTrue);
}); });
testWidgets('Does ContainedButton work with hover', (WidgetTester tester) async { testWidgets('Does ElevatedButton work with hover', (WidgetTester tester) async {
const Color hoverColor = Color(0xff001122); const Color hoverColor = Color(0xff001122);
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: ContainedButton( child: ElevatedButton(
style: ButtonStyle( style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) { overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
return states.contains(MaterialState.hovered) ? hoverColor : null; return states.contains(MaterialState.hovered) ? hoverColor : null;
...@@ -387,7 +387,7 @@ void main() { ...@@ -387,7 +387,7 @@ void main() {
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse); final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
await gesture.addPointer(); await gesture.addPointer();
await gesture.moveTo(tester.getCenter(find.byType(ContainedButton))); await gesture.moveTo(tester.getCenter(find.byType(ElevatedButton)));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures'); final RenderObject inkFeatures = tester.allRenderObjects.firstWhere((RenderObject object) => object.runtimeType.toString() == '_RenderInkFeatures');
...@@ -396,14 +396,14 @@ void main() { ...@@ -396,14 +396,14 @@ void main() {
await gesture.removePointer(); await gesture.removePointer();
}); });
testWidgets('Does ContainedButton work with focus', (WidgetTester tester) async { testWidgets('Does ElevatedButton work with focus', (WidgetTester tester) async {
const Color focusColor = Color(0xff001122); const Color focusColor = Color(0xff001122);
final FocusNode focusNode = FocusNode(debugLabel: 'ContainedButton Node'); final FocusNode focusNode = FocusNode(debugLabel: 'ElevatedButton Node');
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: ContainedButton( child: ElevatedButton(
style: ButtonStyle( style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) { overlayColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) {
return states.contains(MaterialState.focused) ? focusColor : null; return states.contains(MaterialState.focused) ? focusColor : null;
...@@ -424,18 +424,18 @@ void main() { ...@@ -424,18 +424,18 @@ void main() {
expect(inkFeatures, paints..rect(color: focusColor)); expect(inkFeatures, paints..rect(color: focusColor));
}); });
testWidgets('Does ContainedButton work with autofocus', (WidgetTester tester) async { testWidgets('Does ElevatedButton work with autofocus', (WidgetTester tester) async {
const Color focusColor = Color(0xff001122); const Color focusColor = Color(0xff001122);
Color getOverlayColor(Set<MaterialState> states) { Color getOverlayColor(Set<MaterialState> states) {
return states.contains(MaterialState.focused) ? focusColor : null; return states.contains(MaterialState.focused) ? focusColor : null;
} }
final FocusNode focusNode = FocusNode(debugLabel: 'ContainedButton Node'); final FocusNode focusNode = FocusNode(debugLabel: 'ElevatedButton Node');
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: ContainedButton( child: ElevatedButton(
autofocus: true, autofocus: true,
style: ButtonStyle( style: ButtonStyle(
overlayColor: MaterialStateProperty.resolveWith<Color>(getOverlayColor), overlayColor: MaterialStateProperty.resolveWith<Color>(getOverlayColor),
...@@ -454,14 +454,14 @@ void main() { ...@@ -454,14 +454,14 @@ void main() {
expect(inkFeatures, paints..rect(color: focusColor)); expect(inkFeatures, paints..rect(color: focusColor));
}); });
testWidgets('Does ContainedButton contribute semantics', (WidgetTester tester) async { testWidgets('Does ElevatedButton contribute semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Material( child: Material(
child: Center( child: Center(
child: ContainedButton( child: ElevatedButton(
style: ButtonStyle( style: ButtonStyle(
// Specifying minimumSize to mimic the original minimumSize for // Specifying minimumSize to mimic the original minimumSize for
// RaisedButton so that the semantics tree's rect and transform // RaisedButton so that the semantics tree's rect and transform
...@@ -501,7 +501,7 @@ void main() { ...@@ -501,7 +501,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgets('ContainedButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { testWidgets('ElevatedButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
final ButtonStyle style = ButtonStyle( final ButtonStyle style = ButtonStyle(
// Specifying minimumSize to mimic the original minimumSize for // Specifying minimumSize to mimic the original minimumSize for
// RaisedButton so that the corresponding button size matches // RaisedButton so that the corresponding button size matches
...@@ -516,7 +516,7 @@ void main() { ...@@ -516,7 +516,7 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Material( child: Material(
child: Center( child: Center(
child: ContainedButton( child: ElevatedButton(
key: key, key: key,
style: style, style: style,
child: const SizedBox(width: 50.0, height: 8.0), child: const SizedBox(width: 50.0, height: 8.0),
...@@ -537,12 +537,12 @@ void main() { ...@@ -537,12 +537,12 @@ void main() {
expect(tester.getSize(find.byKey(key2)), const Size(88.0, 36.0)); expect(tester.getSize(find.byKey(key2)), const Size(88.0, 36.0));
}); });
testWidgets('ContainedButton has no clip by default', (WidgetTester tester) async { testWidgets('ElevatedButton has no clip by default', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Material( child: Material(
child: ContainedButton( child: ElevatedButton(
onPressed: () { /* to make sure the button is enabled */ }, onPressed: () { /* to make sure the button is enabled */ },
child: const Text('button'), child: const Text('button'),
), ),
...@@ -551,12 +551,12 @@ void main() { ...@@ -551,12 +551,12 @@ void main() {
); );
expect( expect(
tester.renderObject(find.byType(ContainedButton)), tester.renderObject(find.byType(ElevatedButton)),
paintsExactlyCountTimes(#clipPath, 0), paintsExactlyCountTimes(#clipPath, 0),
); );
}); });
testWidgets('ContainedButton responds to density changes.', (WidgetTester tester) async { testWidgets('ElevatedButton responds to density changes.', (WidgetTester tester) async {
const Key key = Key('test'); const Key key = Key('test');
const Key childKey = Key('test child'); const Key childKey = Key('test child');
...@@ -566,7 +566,7 @@ void main() { ...@@ -566,7 +566,7 @@ void main() {
home: Directionality( home: Directionality(
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
child: Center( child: Center(
child: ContainedButton( child: ElevatedButton(
style: ButtonStyle( style: ButtonStyle(
visualDensity: visualDensity, visualDensity: visualDensity,
// Specifying minimumSize to mimic the original minimumSize for // Specifying minimumSize to mimic the original minimumSize for
...@@ -624,7 +624,7 @@ void main() { ...@@ -624,7 +624,7 @@ void main() {
expect(childRect, equals(const Rect.fromLTRB(372.0, 293.0, 428.0, 307.0))); expect(childRect, equals(const Rect.fromLTRB(372.0, 293.0, 428.0, 307.0)));
}); });
testWidgets('ContainedButton.icon responds to applied padding', (WidgetTester tester) async { testWidgets('ElevatedButton.icon responds to applied padding', (WidgetTester tester) async {
const Key buttonKey = Key('test'); const Key buttonKey = Key('test');
const Key labelKey = Key('label'); const Key labelKey = Key('label');
await tester.pumpWidget( await tester.pumpWidget(
...@@ -635,7 +635,7 @@ void main() { ...@@ -635,7 +635,7 @@ void main() {
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: Material( child: Material(
child: Center( child: Center(
child: ContainedButton.icon( child: ElevatedButton.icon(
key: buttonKey, key: buttonKey,
style: ButtonStyle( style: ButtonStyle(
padding: MaterialStateProperty.all<EdgeInsets>(const EdgeInsets.fromLTRB(16, 5, 10, 12)), padding: MaterialStateProperty.all<EdgeInsets>(const EdgeInsets.fromLTRB(16, 5, 10, 12)),
...@@ -666,7 +666,7 @@ void main() { ...@@ -666,7 +666,7 @@ void main() {
expect(paddingRect.bottom, tallerWidget.bottom + 12); expect(paddingRect.bottom, tallerWidget.bottom + 12);
}); });
group('Default ContainedButton padding for textScaleFactor, textDirection', () { group('Default ElevatedButton padding for textScaleFactor, textDirection', () {
const ValueKey<String> buttonKey = ValueKey<String>('button'); const ValueKey<String> buttonKey = ValueKey<String>('button');
const ValueKey<String> labelKey = ValueKey<String>('label'); const ValueKey<String> labelKey = ValueKey<String>('label');
const ValueKey<String> iconKey = ValueKey<String>('icon'); const ValueKey<String> iconKey = ValueKey<String>('icon');
...@@ -746,7 +746,7 @@ void main() { ...@@ -746,7 +746,7 @@ void main() {
for (final double textScaleFactor in textScaleFactorOptions) { for (final double textScaleFactor in textScaleFactorOptions) {
for (final TextDirection textDirection in textDirectionOptions) { for (final TextDirection textDirection in textDirectionOptions) {
for (final Widget icon in iconOptions) { for (final Widget icon in iconOptions) {
final String testName = 'ContainedButton' final String testName = 'ElevatedButton'
', text scale $textScaleFactor' ', text scale $textScaleFactor'
'${icon != null ? ", with icon" : ""}' '${icon != null ? ", with icon" : ""}'
'${textDirection == TextDirection.rtl ? ", RTL" : ""}'; '${textDirection == TextDirection.rtl ? ", RTL" : ""}';
...@@ -766,12 +766,12 @@ void main() { ...@@ -766,12 +766,12 @@ void main() {
child: Scaffold( child: Scaffold(
body: Center( body: Center(
child: icon == null child: icon == null
? ContainedButton( ? ElevatedButton(
key: buttonKey, key: buttonKey,
onPressed: () {}, onPressed: () {},
child: const Text('button', key: labelKey), child: const Text('button', key: labelKey),
) )
: ContainedButton.icon( : ElevatedButton.icon(
key: buttonKey, key: buttonKey,
onPressed: () {}, onPressed: () {},
icon: icon, icon: icon,
...@@ -887,7 +887,7 @@ void main() { ...@@ -887,7 +887,7 @@ void main() {
} }
}); });
testWidgets('Override ContainedButton default padding', (WidgetTester tester) async { testWidgets('Override ElevatedButton default padding', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData.from(colorScheme: const ColorScheme.light()), theme: ThemeData.from(colorScheme: const ColorScheme.light()),
...@@ -899,10 +899,10 @@ void main() { ...@@ -899,10 +899,10 @@ void main() {
), ),
child: Scaffold( child: Scaffold(
body: Center( body: Center(
child: ContainedButton( child: ElevatedButton(
style: ContainedButton.styleFrom(padding: const EdgeInsets.all(22)), style: ElevatedButton.styleFrom(padding: const EdgeInsets.all(22)),
onPressed: () {}, onPressed: () {},
child: const Text('ContainedButton') child: const Text('ElevatedButton')
), ),
), ),
), ),
...@@ -914,7 +914,7 @@ void main() { ...@@ -914,7 +914,7 @@ void main() {
final Padding paddingWidget = tester.widget<Padding>( final Padding paddingWidget = tester.widget<Padding>(
find.descendant( find.descendant(
of: find.byType(ContainedButton), of: find.byType(ElevatedButton),
matching: find.byType(Padding), matching: find.byType(Padding),
), ),
); );
......
...@@ -9,14 +9,14 @@ import 'package:flutter/rendering.dart'; ...@@ -9,14 +9,14 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
void main() { void main() {
testWidgets('Passing no ContainedButtonTheme returns defaults', (WidgetTester tester) async { testWidgets('Passing no ElevatedButtonTheme returns defaults', (WidgetTester tester) async {
const ColorScheme colorScheme = ColorScheme.light(); const ColorScheme colorScheme = ColorScheme.light();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData.from(colorScheme: colorScheme), theme: ThemeData.from(colorScheme: colorScheme),
home: Scaffold( home: Scaffold(
body: Center( body: Center(
child: ContainedButton( child: ElevatedButton(
onPressed: () { }, onPressed: () { },
child: const Text('button'), child: const Text('button'),
), ),
...@@ -26,7 +26,7 @@ void main() { ...@@ -26,7 +26,7 @@ void main() {
); );
final Finder buttonMaterial = find.descendant( final Finder buttonMaterial = find.descendant(
of: find.byType(ContainedButton), of: find.byType(ElevatedButton),
matching: find.byType(Material), matching: find.byType(Material),
); );
...@@ -43,7 +43,7 @@ void main() { ...@@ -43,7 +43,7 @@ void main() {
expect(material.textStyle.fontWeight, FontWeight.w500); expect(material.textStyle.fontWeight, FontWeight.w500);
}); });
group('[Theme, TextTheme, ContainedButton style overrides]', () { group('[Theme, TextTheme, ElevatedButton style overrides]', () {
const Color primaryColor = Color(0xff000001); const Color primaryColor = Color(0xff000001);
const Color onSurfaceColor = Color(0xff000002); const Color onSurfaceColor = Color(0xff000002);
const Color shadowColor = Color(0xff000004); const Color shadowColor = Color(0xff000004);
...@@ -60,7 +60,7 @@ void main() { ...@@ -60,7 +60,7 @@ void main() {
const Duration animationDuration = Duration(milliseconds: 25); const Duration animationDuration = Duration(milliseconds: 25);
const bool enableFeedback = false; const bool enableFeedback = false;
final ButtonStyle style = ContainedButton.styleFrom( final ButtonStyle style = ElevatedButton.styleFrom(
primary: primaryColor, primary: primaryColor,
onPrimary: onPrimaryColor, onPrimary: onPrimaryColor,
onSurface: onSurfaceColor, onSurface: onSurfaceColor,
...@@ -81,7 +81,7 @@ void main() { ...@@ -81,7 +81,7 @@ void main() {
Widget buildFrame({ ButtonStyle buttonStyle, ButtonStyle themeStyle, ButtonStyle overallStyle }) { Widget buildFrame({ ButtonStyle buttonStyle, ButtonStyle themeStyle, ButtonStyle overallStyle }) {
final Widget child = Builder( final Widget child = Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
return ContainedButton( return ElevatedButton(
style: buttonStyle, style: buttonStyle,
onPressed: () { }, onPressed: () { },
child: const Text('button'), child: const Text('button'),
...@@ -90,14 +90,14 @@ void main() { ...@@ -90,14 +90,14 @@ void main() {
); );
return MaterialApp( return MaterialApp(
theme: ThemeData.from(colorScheme: const ColorScheme.light()).copyWith( theme: ThemeData.from(colorScheme: const ColorScheme.light()).copyWith(
containedButtonTheme: ContainedButtonThemeData(style: overallStyle), elevatedButtonTheme: ElevatedButtonThemeData(style: overallStyle),
), ),
home: Scaffold( home: Scaffold(
body: Center( body: Center(
// If the ContainedButtonTheme widget is present, it's used // If the ElevatedButtonTheme widget is present, it's used
// instead of the Theme's ThemeData.containedButtonTheme. // instead of the Theme's ThemeData.ElevatedButtonTheme.
child: themeStyle == null ? child : ContainedButtonTheme( child: themeStyle == null ? child : ElevatedButtonTheme(
data: ContainedButtonThemeData(style: themeStyle), data: ElevatedButtonThemeData(style: themeStyle),
child: child, child: child,
), ),
), ),
...@@ -106,12 +106,12 @@ void main() { ...@@ -106,12 +106,12 @@ void main() {
} }
final Finder findMaterial = find.descendant( final Finder findMaterial = find.descendant(
of: find.byType(ContainedButton), of: find.byType(ElevatedButton),
matching: find.byType(Material), matching: find.byType(Material),
); );
final Finder findInkWell = find.descendant( final Finder findInkWell = find.descendant(
of: find.byType(ContainedButton), of: find.byType(ElevatedButton),
matching: find.byType(InkWell), matching: find.byType(InkWell),
); );
...@@ -138,7 +138,7 @@ void main() { ...@@ -138,7 +138,7 @@ void main() {
expect(material.borderRadius, null); expect(material.borderRadius, null);
expect(material.shape, shape); expect(material.shape, shape);
expect(material.animationDuration, animationDuration); expect(material.animationDuration, animationDuration);
expect(tester.getSize(find.byType(ContainedButton)), const Size(200, 200)); expect(tester.getSize(find.byType(ElevatedButton)), const Size(200, 200));
} }
testWidgets('Button style overrides defaults', (WidgetTester tester) async { testWidgets('Button style overrides defaults', (WidgetTester tester) async {
......
...@@ -285,7 +285,7 @@ void main() { ...@@ -285,7 +285,7 @@ void main() {
bottomNavigationBarTheme: const BottomNavigationBarThemeData(type: BottomNavigationBarType.fixed), bottomNavigationBarTheme: const BottomNavigationBarThemeData(type: BottomNavigationBarType.fixed),
timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.black), timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.black),
textButtonTheme: TextButtonThemeData(style: TextButton.styleFrom(primary: Colors.red)), textButtonTheme: TextButtonThemeData(style: TextButton.styleFrom(primary: Colors.red)),
containedButtonTheme: ContainedButtonThemeData(style: ContainedButton.styleFrom(primary: Colors.green)), elevatedButtonTheme: ElevatedButtonThemeData(style: ElevatedButton.styleFrom(primary: Colors.green)),
outlinedButtonTheme: OutlinedButtonThemeData(style: OutlinedButton.styleFrom(primary: Colors.blue)), outlinedButtonTheme: OutlinedButtonThemeData(style: OutlinedButton.styleFrom(primary: Colors.blue)),
fixTextFieldOutlineLabel: false, fixTextFieldOutlineLabel: false,
); );
...@@ -371,7 +371,7 @@ void main() { ...@@ -371,7 +371,7 @@ void main() {
bottomNavigationBarTheme: const BottomNavigationBarThemeData(type: BottomNavigationBarType.shifting), bottomNavigationBarTheme: const BottomNavigationBarThemeData(type: BottomNavigationBarType.shifting),
timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.white), timePickerTheme: const TimePickerThemeData(backgroundColor: Colors.white),
textButtonTheme: const TextButtonThemeData(), textButtonTheme: const TextButtonThemeData(),
containedButtonTheme: const ContainedButtonThemeData(), elevatedButtonTheme: const ElevatedButtonThemeData(),
outlinedButtonTheme: const OutlinedButtonThemeData(), outlinedButtonTheme: const OutlinedButtonThemeData(),
fixTextFieldOutlineLabel: true, fixTextFieldOutlineLabel: true,
); );
...@@ -443,7 +443,7 @@ void main() { ...@@ -443,7 +443,7 @@ void main() {
bottomNavigationBarTheme: otherTheme.bottomNavigationBarTheme, bottomNavigationBarTheme: otherTheme.bottomNavigationBarTheme,
timePickerTheme: otherTheme.timePickerTheme, timePickerTheme: otherTheme.timePickerTheme,
textButtonTheme: otherTheme.textButtonTheme, textButtonTheme: otherTheme.textButtonTheme,
containedButtonTheme: otherTheme.containedButtonTheme, elevatedButtonTheme: otherTheme.elevatedButtonTheme,
outlinedButtonTheme: otherTheme.outlinedButtonTheme, outlinedButtonTheme: otherTheme.outlinedButtonTheme,
fixTextFieldOutlineLabel: otherTheme.fixTextFieldOutlineLabel, fixTextFieldOutlineLabel: otherTheme.fixTextFieldOutlineLabel,
); );
...@@ -514,7 +514,7 @@ void main() { ...@@ -514,7 +514,7 @@ void main() {
expect(themeDataCopy.bottomNavigationBarTheme, equals(otherTheme.bottomNavigationBarTheme)); expect(themeDataCopy.bottomNavigationBarTheme, equals(otherTheme.bottomNavigationBarTheme));
expect(themeDataCopy.timePickerTheme, equals(otherTheme.timePickerTheme)); expect(themeDataCopy.timePickerTheme, equals(otherTheme.timePickerTheme));
expect(themeDataCopy.textButtonTheme, equals(otherTheme.textButtonTheme)); expect(themeDataCopy.textButtonTheme, equals(otherTheme.textButtonTheme));
expect(themeDataCopy.containedButtonTheme, equals(otherTheme.containedButtonTheme)); expect(themeDataCopy.elevatedButtonTheme, equals(otherTheme.elevatedButtonTheme));
expect(themeDataCopy.outlinedButtonTheme, equals(otherTheme.outlinedButtonTheme)); expect(themeDataCopy.outlinedButtonTheme, equals(otherTheme.outlinedButtonTheme));
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