Unverified Commit afe6c2e7 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Remove deprecated RaisedButton (#98547)

parent 94fefaa4
......@@ -118,7 +118,6 @@ export 'src/material/progress_indicator_theme.dart';
export 'src/material/radio.dart';
export 'src/material/radio_list_tile.dart';
export 'src/material/radio_theme.dart';
export 'src/material/raised_button.dart';
export 'src/material/range_slider.dart';
export 'src/material/refresh_indicator.dart';
export 'src/material/reorderable_list.dart';
......
......@@ -26,11 +26,8 @@ import 'theme_data.dart';
/// [ButtonStyle] of a [TextButton], [ElevatedButton] or an
/// [OutlinedButton].
///
/// FlatButton and RaisedButton have been replaced by
/// TextButton and ElevatedButton respectively.
/// ButtonTheme has been replaced by TextButtonTheme and
/// ElevatedButtonTheme. The original classes
/// have been deprecated, please migrate code that uses them.
/// FlatButton has been replaced by TextButton and ButtonTheme has been
/// replaced by TextButtonTheme. Please migrate code that uses them.
/// There's a detailed migration guide for the new button and button
/// theme classes in
/// [flutter.dev/go/material-button-migration-guide](https://flutter.dev/go/material-button-migration-guide).
......
......@@ -11,7 +11,6 @@ import 'constants.dart';
import 'flat_button.dart';
import 'material_button.dart';
import 'material_state.dart';
import 'raised_button.dart';
import 'theme.dart';
import 'theme_data.dart' show MaterialTapTargetSize;
......@@ -21,8 +20,7 @@ import 'theme_data.dart' show MaterialTapTargetSize;
///
/// See also:
///
/// * [RaisedButton] and [FlatButton] which are configured
/// based on the ambient [ButtonTheme].
/// * [FlatButton] which is configured based on the ambient [ButtonTheme].
enum ButtonTextTheme {
/// Button text is black or white depending on [ThemeData.brightness].
normal,
......@@ -68,8 +66,7 @@ enum ButtonBarLayoutBehavior {
///
/// See also:
///
/// * [FlatButton] and [RaisedButton] which are styled
/// based on the ambient button theme.
/// * [FlatButton] which is styled based on the ambient button theme.
/// * [RawMaterialButton], which can be used to configure a button that doesn't
/// depend on any inherited themes.
class ButtonTheme extends InheritedTheme {
......@@ -174,11 +171,9 @@ class ButtonTheme extends InheritedTheme {
/// * [ElevatedButton], [ElevatedButtonTheme], [ElevatedButtonThemeData],
/// * [OutlinedButton], [OutlinedButtonTheme], [OutlinedButtonThemeData]
///
/// FlatButton and RaisedButton have been replaced by
/// TextButton and ElevatedButton respectively.
/// ButtonTheme has been replaced by TextButtonTheme and
/// ElevatedButtonTheme. The original classes
/// have been deprecated, please migrate code that uses them.
/// FlatButton has been replaced by TextButton and ButtonTheme has been replaced
/// by TextButtonTheme. Please migrate code that uses them.
///
/// There's a detailed migration guide for the new button and button
/// theme classes in
/// [flutter.dev/go/material-button-migration-guide](https://flutter.dev/go/material-button-migration-guide).
......@@ -196,8 +191,8 @@ class ButtonThemeData with Diagnosticable {
/// [height] parameters must greater than or equal to zero.
///
/// The ButtonTheme's methods that have a [MaterialButton] parameter and
/// have a name with a `get` prefix are used by [RaisedButton]
/// and [FlatButton] to configure a [RawMaterialButton].
/// have a name with a `get` prefix are used by [FlatButton] to configure a
/// [RawMaterialButton].
const ButtonThemeData({
this.textTheme = ButtonTextTheme.normal,
this.minWidth = 88.0,
......@@ -278,7 +273,7 @@ class ButtonThemeData with Diagnosticable {
///
/// See also:
///
/// * [getPadding], which is used by [RaisedButton] and [FlatButton].
/// * [getPadding], which is used by [FlatButton].
EdgeInsetsGeometry get padding {
if (_padding != null)
return _padding!;
......@@ -304,7 +299,7 @@ class ButtonThemeData with Diagnosticable {
///
/// See also:
///
/// * [getShape], which is used by [RaisedButton] and [FlatButton].
/// * [getShape], which is used by [FlatButton].
ShapeBorder get shape {
if (_shape != null)
return _shape!;
......@@ -333,7 +328,7 @@ class ButtonThemeData with Diagnosticable {
/// This property only affects [DropdownButton] and its menu.
final bool alignedDropdown;
/// The background fill color for [RaisedButton]s.
/// The background fill color.
///
/// This property is null by default.
///
......@@ -343,18 +338,17 @@ class ButtonThemeData with Diagnosticable {
///
/// See also:
///
/// * [getFillColor], which is used by [RaisedButton] to compute its
/// background fill color.
/// * [getFillColor], which is used to compute the background fill color.
final Color? _buttonColor;
/// The background fill color for disabled [RaisedButton]s.
/// The background fill color when disabled.
///
/// This property is null by default.
///
/// See also:
///
/// * [getDisabledFillColor], which is used by [RaisedButton] to compute its
/// background fill color.
/// * [getDisabledFillColor], which is to compute background fill color for
/// disabled state.
final Color? _disabledColor;
/// The fill color of the button when it has the input focus.
......@@ -366,7 +360,7 @@ class ButtonThemeData with Diagnosticable {
///
/// See also:
///
/// * [getFocusColor], which is used by [RaisedButton] and [FlatButton].
/// * [getFocusColor], which is used by [FlatButton].
final Color? _focusColor;
/// The fill color of the button when a pointer is hovering over it.
......@@ -378,7 +372,7 @@ class ButtonThemeData with Diagnosticable {
///
/// See also:
///
/// * [getHoverColor], which is used by [RaisedButton] and [FlatButton].
/// * [getHoverColor], which is used by [FlatButton].
final Color? _hoverColor;
/// The color of the overlay that appears when a button is pressed.
......@@ -387,7 +381,7 @@ class ButtonThemeData with Diagnosticable {
///
/// See also:
///
/// * [getHighlightColor], which is used by [RaisedButton] and [FlatButton].
/// * [getHighlightColor], which is used by [FlatButton].
final Color? _highlightColor;
/// The color of the ink "splash" overlay that appears when a button is tapped.
......@@ -396,7 +390,7 @@ class ButtonThemeData with Diagnosticable {
///
/// See also:
///
/// * [getSplashColor], which is used by [RaisedButton] and [FlatButton].
/// * [getSplashColor], which is used by [FlatButton].
final Color? _splashColor;
/// A set of thirteen colors that can be used to derive the button theme's
......@@ -417,7 +411,7 @@ class ButtonThemeData with Diagnosticable {
//
// See also:
//
// * [getMaterialTargetTapSize], which is used by [RaisedButton] and [FlatButton].
// * [getMaterialTargetTapSize], which is used by [FlatButton].
final MaterialTapTargetSize? _materialTapTargetSize;
/// The [button]'s overall brightness.
......@@ -484,9 +478,6 @@ class ButtonThemeData with Diagnosticable {
/// Otherwise, if button is a [FlatButton] then null is
/// returned.
///
/// Otherwise, if button is a [RaisedButton], returns the `buttonColor`
/// constructor parameter if it was non-null and the button is enabled.
///
/// Otherwise the fill color depends on the value of [getTextTheme].
///
/// * [ButtonTextTheme.normal] or [ButtonTextTheme.accent], the
......@@ -505,7 +496,7 @@ class ButtonThemeData with Diagnosticable {
if (button is FlatButton || button.runtimeType == MaterialButton)
return null;
if (button.enabled && button is RaisedButton && _buttonColor != null)
if (button.enabled && _buttonColor != null)
return _buttonColor;
switch (getTextTheme(button)) {
......@@ -569,7 +560,7 @@ class ButtonThemeData with Diagnosticable {
/// Returns the button's [MaterialButton.splashColor] if it is non-null.
///
/// Otherwise, returns the value of the `splashColor` constructor parameter
/// it is non-null and [button] is a [RaisedButton].
/// it is non-null.
///
/// Otherwise, returns the value of the `splashColor` constructor parameter
/// if it is non-null and [button] is a [FlatButton] and
......@@ -580,7 +571,7 @@ class ButtonThemeData with Diagnosticable {
if (button.splashColor != null)
return button.splashColor!;
if (_splashColor != null && button is RaisedButton)
if (_splashColor != null)
return _splashColor!;
if (_splashColor != null && button is FlatButton) {
......@@ -715,8 +706,8 @@ class ButtonThemeData with Diagnosticable {
///
/// Returns the button's [MaterialButton.padding] if it is non-null.
///
/// If this is a button constructed with [RaisedButton.icon] or
/// [FlatButton.icon] then the padding is:
/// If this is a button constructed with [FlatButton.icon] then the padding
/// is:
/// `EdgeInsetsDirectional.only(start: 12.0, end: 16.0)`.
///
/// Otherwise, returns [padding] if it is non-null.
......
......@@ -14,11 +14,8 @@ import 'theme_data.dart';
///
/// ### This class is deprecated, please use [TextButton] instead.
///
/// FlatButton and RaisedButton have been replaced by
/// [TextButton] and [ElevatedButton] respectively.
/// ButtonTheme has been replaced by [TextButtonTheme] and
/// [ElevatedButtonTheme]. The original classes
/// will eventually be removed, please migrate code that uses them.
/// FlatButton have been replaced by [TextButton] and ButtonTheme has been
/// replaced by [TextButtonTheme]. Please migrate code that uses them.
/// There's a detailed migration guide for the new button and button
/// theme classes in
/// [flutter.dev/go/material-button-migration-guide](https://flutter.dev/go/material-button-migration-guide).
......
......@@ -21,10 +21,8 @@ import 'theme_data.dart';
///
/// ### This class is obsolete.
///
/// FlatButton and RaisedButton have been replaced by
/// TextButton and ElevatedButton respectively.
/// ButtonTheme has been replaced by TextButtonTheme and
/// ElevatedButtonTheme. The appearance of the
/// FlatButton has been replaced by TextButton and ButtonTheme has been replaced
/// by TextButtonTheme. The appearance of the
/// new widgets can be customized by specifying a [ButtonStyle]
/// or by creating a one-off style using a `styleFrom` method like
/// [TextButton.styleFrom]. The original button classes
......@@ -38,9 +36,9 @@ import 'theme_data.dart';
/// MaterialButtons whose [onPressed] and [onLongPress] callbacks are null will be disabled. To have
/// an enabled button, make sure to pass a non-null value for [onPressed] or [onLongPress].
///
/// Rather than using this class directly, consider using [FlatButton]
/// or [RaisedButton], which configure this class with
/// appropriate defaults that match the material design specification.
/// Rather than using this class directly, consider using [FlatButton], which
/// configure this class with appropriate defaults that match the material
/// design specification.
///
/// To create a button directly, without inheriting theme defaults, use
/// [RawMaterialButton].
......@@ -55,7 +53,7 @@ class MaterialButton extends StatelessWidget {
/// Creates a material button.
///
/// Rather than creating a material button directly, consider using
/// [FlatButton] or [RaisedButton]. To create a custom Material button
/// [FlatButton]. To create a custom Material button
/// consider using [RawMaterialButton].
///
/// The [autofocus] and [clipBehavior] arguments must not be null.
......@@ -457,8 +455,7 @@ class MaterialButton extends StatelessWidget {
}
}
/// The type of [MaterialButton]s created with RaisedButton.icon] and
/// FlatButton.icon.
/// The type of [MaterialButton]s created with FlatButton.icon.
///
/// This mixin only exists to give the "label and icon" button widgets a distinct
/// type for the sake of [ButtonTheme].
......
This diff is collapsed.
......@@ -115,7 +115,6 @@ const Color _kDarkThemeSplashColor = Color(0x40CCCCCC);
/// * [TextButton]
/// * [ElevatedButton]
/// * [FlatButton]
/// * [RaisedButton]
/// * The time picker widget ([showTimePicker])
/// * [SnackBar]
/// * [Chip]
......@@ -524,7 +523,6 @@ class ThemeData with Diagnosticable {
// [disabledColor], [highlightColor], and [splashColor].
buttonTheme ??= ButtonThemeData(
colorScheme: colorScheme,
// Defaults to the fill color for RaisedButtons for backwards compatibility.
buttonColor: buttonColor ?? (isDark ? primarySwatch[600]! : Colors.grey[300]!),
disabledColor: disabledColor,
focusColor: focusColor,
......@@ -1423,8 +1421,7 @@ class ThemeData with Diagnosticable {
/// A theme for customizing the appearance and layout of [ButtonBar] widgets.
final ButtonBarThemeData buttonBarTheme;
/// Defines the default configuration of button widgets, like [RaisedButton]
/// and [FlatButton].
/// Defines the default configuration of button widgets, like [FlatButton].
final ButtonThemeData buttonTheme;
/// The colors and styles used to render [Card].
......@@ -1627,7 +1624,7 @@ class ThemeData with Diagnosticable {
)
final IconThemeData accentIconTheme;
/// The default fill color of the [Material] used in [RaisedButton]s.
/// The default fill color of the [Material].
@Deprecated(
'No longer used by the framework, please remove any reference to it. '
'This feature was deprecated after v2.3.0-0.2.pre.',
......
......@@ -117,112 +117,6 @@ void main() {
expect(theme.colorScheme, const ColorScheme.dark());
});
testWidgets('Theme buttonTheme defaults', (WidgetTester tester) async {
final ThemeData lightTheme = ThemeData.light();
late ButtonTextTheme textTheme;
late BoxConstraints constraints;
late EdgeInsets padding;
late ShapeBorder shape;
const Color disabledColor = Color(0xFF00FF00);
await tester.pumpWidget(
Theme(
data: lightTheme.copyWith(
disabledColor: disabledColor, // disabled RaisedButton fill color
buttonTheme: const ButtonThemeData(disabledColor: disabledColor),
textTheme: lightTheme.textTheme.copyWith(
button: lightTheme.textTheme.button!.copyWith(
// The button's height will match because there's no
// vertical padding by default
fontSize: 48.0,
),
),
),
child: Builder(
builder: (BuildContext context) {
final ButtonThemeData theme = ButtonTheme.of(context);
textTheme = theme.textTheme;
constraints = theme.constraints;
padding = theme.padding as EdgeInsets;
shape = theme.shape;
return Container(
alignment: Alignment.topLeft,
child: const Directionality(
textDirection: TextDirection.ltr,
child: RaisedButton(
onPressed: null,
child: Text('b'), // intrinsic width < minimum width
),
),
);
},
),
),
);
expect(textTheme, ButtonTextTheme.normal);
expect(constraints, const BoxConstraints(minWidth: 88.0, minHeight: 36.0));
expect(padding, const EdgeInsets.symmetric(horizontal: 16.0));
expect(shape, const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(2.0)),
));
expect(tester.widget<Material>(find.byType(Material)).shape, shape);
expect(tester.widget<Material>(find.byType(Material)).color, disabledColor);
expect(tester.getSize(find.byType(Material)), const Size(88.0, 48.0));
});
testWidgets('Theme buttonTheme ButtonTheme overrides', (WidgetTester tester) async {
late ButtonTextTheme textTheme;
late BoxConstraints constraints;
late EdgeInsets padding;
late ShapeBorder shape;
await tester.pumpWidget(
Theme(
data: ThemeData.light().copyWith(
buttonColor: const Color(0xFF00FF00), // enabled RaisedButton fill color
),
child: ButtonTheme(
textTheme: ButtonTextTheme.primary,
minWidth: 100.0,
height: 200.0,
padding: EdgeInsets.zero,
buttonColor: const Color(0xFF00FF00), // enabled RaisedButton fill color
shape: const RoundedRectangleBorder(),
child: Builder(
builder: (BuildContext context) {
final ButtonThemeData theme = ButtonTheme.of(context);
textTheme = theme.textTheme;
constraints = theme.constraints;
padding = theme.padding as EdgeInsets;
shape = theme.shape;
return Container(
alignment: Alignment.topLeft,
child: Directionality(
textDirection: TextDirection.ltr,
child: RaisedButton(
onPressed: () { },
child: const Text('b'), // intrinsic width < minimum width
),
),
);
},
),
),
),
);
expect(textTheme, ButtonTextTheme.primary);
expect(constraints, const BoxConstraints(minWidth: 100.0, minHeight: 200.0));
expect(padding, EdgeInsets.zero);
expect(shape, const RoundedRectangleBorder());
expect(tester.widget<Material>(find.byType(Material)).shape, shape);
expect(tester.widget<Material>(find.byType(Material)).color, const Color(0xFF00FF00));
expect(tester.getSize(find.byType(Material)), const Size(100.0, 200.0));
});
testWidgets('ButtonTheme alignedDropdown', (WidgetTester tester) async {
final Key dropdownKey = UniqueKey();
......
......@@ -607,99 +607,5 @@ void main() {
await tester.pumpAndSettle(); // route animation
expect(getTextColor('selected'), isNot(selectedButtonColor));
expect(getTextColor('unselected'), isNot(buttonColor));
});
testWidgets('ButtonTheme.wrap()', (WidgetTester tester) async {
const Color buttonColor = Color(0xFF00FF00);
const Color disabledButtonColor = Color(0xFFFF0000);
final Widget buttons = Scaffold(
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const RaisedButton(onPressed: null, child: Text('disabled')),
RaisedButton(child: const Text('enabled'), onPressed: () { }),
],
),
),
);
late BuildContext navigatorContext;
Widget buildFrame() {
return MaterialApp(
home: Scaffold(
body: ButtonTheme.fromButtonThemeData(
data: const ButtonThemeData(
buttonColor: buttonColor,
disabledColor: disabledButtonColor,
),
child: Builder( // Introduce a context so the shadow ButtonTheme is visible to captureAll().
builder: (BuildContext context) {
navigatorContext = context;
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
RaisedButton(
child: const Text('push unwrapped'),
onPressed: () {
Navigator.of(context).push<void>(
MaterialPageRoute<void>(
// The slider will see the default ButtonTheme when built.
builder: (BuildContext _) => buttons,
),
);
},
),
RaisedButton(
child: const Text('push wrapped'),
onPressed: () {
Navigator.of(context).push<void>(
MaterialPageRoute<void>(
// Capture the shadow toggleButtons.
builder: (BuildContext _) => InheritedTheme.captureAll(context, buttons),
),
);
},
),
],
),
);
},
),
),
),
);
}
Color getButtonColor(String text) {
return tester.widget<Material>(
find.descendant(
of: find.widgetWithText(RawMaterialButton, text),
matching: find.byType(Material),
),
).color!;
}
await tester.pumpWidget(buildFrame());
// Show a route which contains toggleButtons.
await tester.tap(find.text('push wrapped'));
await tester.pumpAndSettle(); // route animation
expect(getButtonColor('disabled'), disabledButtonColor);
expect(getButtonColor('enabled'), buttonColor);
Navigator.of(navigatorContext).pop();
await tester.pumpAndSettle(); // route animation
await tester.tap(find.text('push unwrapped'));
await tester.pumpAndSettle(); // route animation
expect(getButtonColor('disabled'), isNot(disabledButtonColor));
expect(getButtonColor('enabled'), isNot(buttonColor));
});
}
This diff is collapsed.
......@@ -10364,11 +10364,11 @@ void main() {
onTap: () { textFieldTapCount += 1; },
decoration: InputDecoration(
labelText: 'Label',
prefix: RaisedButton(
prefix: ElevatedButton(
onPressed: () { prefixTapCount += 1; },
child: const Text('prefix'),
),
suffix: RaisedButton(
suffix: ElevatedButton(
onPressed: () { suffixTapCount += 1; },
child: const Text('suffix'),
),
......
......@@ -11,64 +11,6 @@ const BoxConstraints defaultButtonConstraints = BoxConstraints(minWidth: 88.0, m
const Duration defaultButtonDuration = Duration(milliseconds: 200);
void main() {
group('RaisedButton', () {
testWidgets('theme: ThemeData.light(), enabled: true', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData.light(),
home: Center(
child: RaisedButton(
onPressed: () { }, // button.enabled == true
child: const Text('button'),
),
),
),
);
final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton));
expect(raw.textStyle!.color, const Color(0xdd000000));
expect(raw.fillColor, const Color(0xffe0e0e0));
expect(raw.highlightColor, const Color(0x29000000)); // Was Color(0x66bcbcbc)
expect(raw.splashColor, const Color(0x1f000000)); // Was Color(0x66c8c8c8)
expect(raw.elevation, 2.0);
expect(raw.highlightElevation, 8.0);
expect(raw.disabledElevation, 0.0);
expect(raw.constraints, defaultButtonConstraints);
expect(raw.padding, defaultButtonPadding);
expect(raw.shape, defaultButtonShape);
expect(raw.animationDuration, defaultButtonDuration);
expect(raw.materialTapTargetSize, MaterialTapTargetSize.padded);
});
testWidgets('theme: ThemeData.light(), enabled: false', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData.light(),
home: const Center(
child: RaisedButton(
onPressed: null, // button.enabled == false
child: Text('button'),
),
),
),
);
final RawMaterialButton raw = tester.widget<RawMaterialButton>(find.byType(RawMaterialButton));
expect(raw.textStyle!.color, const Color(0x61000000));
expect(raw.fillColor, const Color(0x61000000));
// highlightColor, disabled button can't be pressed
// splashColor, disabled button doesn't splash
expect(raw.elevation, 2.0);
expect(raw.highlightElevation, 8.0);
expect(raw.disabledElevation, 0.0);
expect(raw.constraints, defaultButtonConstraints);
expect(raw.padding, defaultButtonPadding);
expect(raw.shape, defaultButtonShape);
expect(raw.animationDuration, defaultButtonDuration);
expect(raw.materialTapTargetSize, MaterialTapTargetSize.padded);
});
});
group('FlatButton', () {
testWidgets('theme: ThemeData.light(), enabled: true', (WidgetTester tester) async {
await tester.pumpWidget(
......
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