diff --git a/packages/flutter/lib/fix_data/fix_material/fix_button_bar.yaml b/packages/flutter/lib/fix_data/fix_material/fix_button_bar.yaml new file mode 100644 index 0000000000..597ad91b08 --- /dev/null +++ b/packages/flutter/lib/fix_data/fix_material/fix_button_bar.yaml @@ -0,0 +1,40 @@ +# Copyright 2014 The Flutter Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# For details regarding the *Flutter Fix* feature, see +# https://flutter.dev/docs/development/tools/flutter-fix + +# Please add new fixes to the top of the file, separated by one blank line +# from other fixes. In a comment, include a link to the PR where the change +# requiring the fix was made. + +# Every fix must be tested. See the flutter/packages/flutter/test_fixes/README.md +# file for instructions on testing these data driven fixes. + +# For documentation about this file format, see +# https://dart.dev/go/data-driven-fixes. + +# * Fixes in this file are for ButtonBar from the Material library. * +# For fixes to +# * AppBarTheme: fix_app_bar_theme.yaml +# * AppBar: fix_app_bar.yaml +# * ButtonBar: fix_button_bar.yaml +# * ColorScheme: fix_color_scheme.yaml +# * Material (general): fix_material.yaml +# * SliverAppBar: fix_sliver_app_bar.yaml +# * TextTheme: fix_text_theme.yaml +# * ThemeData: fix_theme_data.yaml +version: 1 +transforms: + # Changes made in https://github.com/flutter/flutter/pull/145523 + - title: "Migrate to 'OverflowBar'" + date: 2024-02-28 + element: + uris: [ 'material.dart' ] + class: 'ButtonBar' + changes: + - kind: 'rename' + newName: 'OverflowBar' + +# Before adding a new fix: read instructions at the top of this file. diff --git a/packages/flutter/lib/fix_data/fix_material/fix_theme_data.yaml b/packages/flutter/lib/fix_data/fix_material/fix_theme_data.yaml index cd579def7c..818858adfe 100644 --- a/packages/flutter/lib/fix_data/fix_material/fix_theme_data.yaml +++ b/packages/flutter/lib/fix_data/fix_material/fix_theme_data.yaml @@ -1698,4 +1698,15 @@ transforms: - kind: 'removeParameter' name: 'useMaterial3' + # Changes made in https://github.com/flutter/flutter/pull/145523 + - title: "Remove 'buttonBarTheme'" + date: 2024-04-28 + element: + uris: [ 'material.dart' ] + constructor: '' + inClass: 'ThemeData' + changes: + - kind: 'removeParameter' + name: 'buttonBarTheme' + # Before adding a new fix: read instructions at the top of this file. diff --git a/packages/flutter/lib/src/material/button_bar.dart b/packages/flutter/lib/src/material/button_bar.dart index 10c7b0a8b5..d89d753d81 100644 --- a/packages/flutter/lib/src/material/button_bar.dart +++ b/packages/flutter/lib/src/material/button_bar.dart @@ -79,11 +79,19 @@ import 'dialog.dart'; /// * [Card], at the bottom of which it is common to place a [ButtonBar]. /// * [Dialog], which uses a [ButtonBar] for its actions. /// * [ButtonBarTheme], which configures the [ButtonBar]. +@Deprecated( + 'Use OverflowBar instead. ' + 'This feature was deprecated after v3.21.0-10.0.pre.', +) class ButtonBar extends StatelessWidget { /// Creates a button bar. /// /// Both [buttonMinWidth] and [buttonHeight] must be non-negative if they /// are not null. + @Deprecated( + 'Use OverflowBar instead. ' + 'This feature was deprecated after v3.21.0-10.0.pre.', + ) const ButtonBar({ super.key, this.alignment, diff --git a/packages/flutter/lib/src/material/button_bar_theme.dart b/packages/flutter/lib/src/material/button_bar_theme.dart index b5bf1ddfb8..e73be8d7f7 100644 --- a/packages/flutter/lib/src/material/button_bar_theme.dart +++ b/packages/flutter/lib/src/material/button_bar_theme.dart @@ -27,12 +27,20 @@ import 'theme.dart'; /// its subtree. /// * [ButtonBar], which uses this to configure itself and its children /// button widgets. +@Deprecated( + 'Use OverflowBar instead. ' + 'This feature was deprecated after v3.21.0-10.0.pre.', +) @immutable class ButtonBarThemeData with Diagnosticable { /// Constructs the set of properties used to configure [ButtonBar] widgets. /// /// Both [buttonMinWidth] and [buttonHeight] must be non-negative if they /// are not null. + @Deprecated( + 'Use OverflowBar instead. ' + 'This feature was deprecated after v3.21.0-10.0.pre.', + ) const ButtonBarThemeData({ this.alignment, this.mainAxisSize, diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index 1378bdfc3e..a33dfb53a5 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -327,7 +327,6 @@ class ThemeData with Diagnosticable { BottomAppBarTheme? bottomAppBarTheme, BottomNavigationBarThemeData? bottomNavigationBarTheme, BottomSheetThemeData? bottomSheetTheme, - ButtonBarThemeData? buttonBarTheme, ButtonThemeData? buttonTheme, CardTheme? cardTheme, CheckboxThemeData? checkboxTheme, @@ -366,6 +365,11 @@ class ThemeData with Diagnosticable { TimePickerThemeData? timePickerTheme, ToggleButtonsThemeData? toggleButtonsTheme, TooltipThemeData? tooltipTheme, + @Deprecated( + 'Use OverflowBar instead. ' + 'This feature was deprecated after v3.21.0-10.0.pre.', + ) + ButtonBarThemeData? buttonBarTheme, }) { // GENERAL CONFIGURATION cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault(); @@ -500,7 +504,6 @@ class ThemeData with Diagnosticable { bottomAppBarTheme ??= const BottomAppBarTheme(); bottomNavigationBarTheme ??= const BottomNavigationBarThemeData(); bottomSheetTheme ??= const BottomSheetThemeData(); - buttonBarTheme ??= const ButtonBarThemeData(); cardTheme ??= const CardTheme(); checkboxTheme ??= const CheckboxThemeData(); chipTheme ??= const ChipThemeData(); @@ -538,6 +541,8 @@ class ThemeData with Diagnosticable { timePickerTheme ??= const TimePickerThemeData(); toggleButtonsTheme ??= const ToggleButtonsThemeData(); tooltipTheme ??= const TooltipThemeData(); + // DEPRECATED (newest deprecations at the bottom) + buttonBarTheme ??= const ButtonBarThemeData(); return ThemeData.raw( // For the sanity of the reader, make sure these properties are in the same // order in every place that they are separated by section comments (e.g. @@ -591,7 +596,6 @@ class ThemeData with Diagnosticable { bottomAppBarTheme: bottomAppBarTheme, bottomNavigationBarTheme: bottomNavigationBarTheme, bottomSheetTheme: bottomSheetTheme, - buttonBarTheme: buttonBarTheme, buttonTheme: buttonTheme, cardTheme: cardTheme, checkboxTheme: checkboxTheme, @@ -630,6 +634,8 @@ class ThemeData with Diagnosticable { timePickerTheme: timePickerTheme, toggleButtonsTheme: toggleButtonsTheme, tooltipTheme: tooltipTheme, + // DEPRECATED (newest deprecations at the bottom) + buttonBarTheme: buttonBarTheme, ); } @@ -696,7 +702,6 @@ class ThemeData with Diagnosticable { required this.bottomAppBarTheme, required this.bottomNavigationBarTheme, required this.bottomSheetTheme, - required this.buttonBarTheme, required this.buttonTheme, required this.cardTheme, required this.checkboxTheme, @@ -735,7 +740,17 @@ class ThemeData with Diagnosticable { required this.timePickerTheme, required this.toggleButtonsTheme, required this.tooltipTheme, - }); + // DEPRECATED (newest deprecations at the bottom) + @Deprecated( + 'Use OverflowBar instead. ' + 'This feature was deprecated after v3.21.0-10.0.pre.', + ) + ButtonBarThemeData? buttonBarTheme, + }) : // DEPRECATED (newest deprecations at the bottom) + // should not be `required`, use getter pattern to avoid breakages. + _buttonBarTheme = buttonBarTheme, + // DEPRECATED (newest deprecations at the bottom) + assert(buttonBarTheme != null); /// Create a [ThemeData] based on the colors in the given [colorScheme] and /// text styles of the optional [textTheme]. @@ -1248,9 +1263,6 @@ class ThemeData with Diagnosticable { /// A theme for customizing the color, elevation, and shape of a bottom sheet. final BottomSheetThemeData bottomSheetTheme; - /// A theme for customizing the appearance and layout of [ButtonBar] widgets. - final ButtonBarThemeData buttonBarTheme; - /// Defines the default configuration of button widgets, like [DropdownButton] /// and [ButtonBar]. final ButtonThemeData buttonTheme; @@ -1390,6 +1402,14 @@ class ThemeData with Diagnosticable { /// This is the value returned from [TooltipTheme.of]. final TooltipThemeData tooltipTheme; + /// A theme for customizing the appearance and layout of [ButtonBar] widgets. + @Deprecated( + 'Use OverflowBar instead. ' + 'This feature was deprecated after v3.21.0-10.0.pre.', + ) + ButtonBarThemeData get buttonBarTheme => _buttonBarTheme!; + final ButtonBarThemeData? _buttonBarTheme; + /// Creates a copy of this theme but with the given fields replaced with the new values. /// /// The [brightness] value is applied to the [colorScheme]. @@ -1449,7 +1469,6 @@ class ThemeData with Diagnosticable { BottomAppBarTheme? bottomAppBarTheme, BottomNavigationBarThemeData? bottomNavigationBarTheme, BottomSheetThemeData? bottomSheetTheme, - ButtonBarThemeData? buttonBarTheme, ButtonThemeData? buttonTheme, CardTheme? cardTheme, CheckboxThemeData? checkboxTheme, @@ -1497,6 +1516,11 @@ class ThemeData with Diagnosticable { 'This feature was deprecated after v3.13.0-0.2.pre.', ) bool? useMaterial3, + @Deprecated( + 'Use OverflowBar instead. ' + 'This feature was deprecated after v3.21.0-10.0.pre.', + ) + ButtonBarThemeData? buttonBarTheme, }) { cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault(); return ThemeData.raw( @@ -1554,7 +1578,6 @@ class ThemeData with Diagnosticable { bottomAppBarTheme: bottomAppBarTheme ?? this.bottomAppBarTheme, bottomNavigationBarTheme: bottomNavigationBarTheme ?? this.bottomNavigationBarTheme, bottomSheetTheme: bottomSheetTheme ?? this.bottomSheetTheme, - buttonBarTheme: buttonBarTheme ?? this.buttonBarTheme, buttonTheme: buttonTheme ?? this.buttonTheme, cardTheme: cardTheme ?? this.cardTheme, checkboxTheme: checkboxTheme ?? this.checkboxTheme, @@ -1593,6 +1616,7 @@ class ThemeData with Diagnosticable { timePickerTheme: timePickerTheme ?? this.timePickerTheme, toggleButtonsTheme: toggleButtonsTheme ?? this.toggleButtonsTheme, tooltipTheme: tooltipTheme ?? this.tooltipTheme, + buttonBarTheme: buttonBarTheme ?? _buttonBarTheme, ); } @@ -1747,7 +1771,6 @@ class ThemeData with Diagnosticable { bottomAppBarTheme: BottomAppBarTheme.lerp(a.bottomAppBarTheme, b.bottomAppBarTheme, t), bottomNavigationBarTheme: BottomNavigationBarThemeData.lerp(a.bottomNavigationBarTheme, b.bottomNavigationBarTheme, t), bottomSheetTheme: BottomSheetThemeData.lerp(a.bottomSheetTheme, b.bottomSheetTheme, t)!, - buttonBarTheme: ButtonBarThemeData.lerp(a.buttonBarTheme, b.buttonBarTheme, t)!, buttonTheme: t < 0.5 ? a.buttonTheme : b.buttonTheme, cardTheme: CardTheme.lerp(a.cardTheme, b.cardTheme, t), checkboxTheme: CheckboxThemeData.lerp(a.checkboxTheme, b.checkboxTheme, t), @@ -1786,6 +1809,7 @@ class ThemeData with Diagnosticable { timePickerTheme: TimePickerThemeData.lerp(a.timePickerTheme, b.timePickerTheme, t), toggleButtonsTheme: ToggleButtonsThemeData.lerp(a.toggleButtonsTheme, b.toggleButtonsTheme, t)!, tooltipTheme: TooltipThemeData.lerp(a.tooltipTheme, b.tooltipTheme, t)!, + buttonBarTheme: ButtonBarThemeData.lerp(a.buttonBarTheme, b.buttonBarTheme, t), ); } @@ -1847,7 +1871,6 @@ class ThemeData with Diagnosticable { other.bottomAppBarTheme == bottomAppBarTheme && other.bottomNavigationBarTheme == bottomNavigationBarTheme && other.bottomSheetTheme == bottomSheetTheme && - other.buttonBarTheme == buttonBarTheme && other.buttonTheme == buttonTheme && other.cardTheme == cardTheme && other.checkboxTheme == checkboxTheme && @@ -1885,7 +1908,8 @@ class ThemeData with Diagnosticable { other.textSelectionTheme == textSelectionTheme && other.timePickerTheme == timePickerTheme && other.toggleButtonsTheme == toggleButtonsTheme && - other.tooltipTheme == tooltipTheme; + other.tooltipTheme == tooltipTheme && + other.buttonBarTheme == buttonBarTheme; } @override @@ -1945,7 +1969,6 @@ class ThemeData with Diagnosticable { bottomAppBarTheme, bottomNavigationBarTheme, bottomSheetTheme, - buttonBarTheme, buttonTheme, cardTheme, checkboxTheme, @@ -1984,6 +2007,8 @@ class ThemeData with Diagnosticable { timePickerTheme, toggleButtonsTheme, tooltipTheme, + // DEPRECATED (newest deprecations at the bottom) + buttonBarTheme, ]; return Object.hashAll(values); } @@ -2044,7 +2069,6 @@ class ThemeData with Diagnosticable { properties.add(DiagnosticsProperty('bottomAppBarTheme', bottomAppBarTheme, defaultValue: defaultData.bottomAppBarTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('bottomNavigationBarTheme', bottomNavigationBarTheme, defaultValue: defaultData.bottomNavigationBarTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('bottomSheetTheme', bottomSheetTheme, defaultValue: defaultData.bottomSheetTheme, level: DiagnosticLevel.debug)); - properties.add(DiagnosticsProperty('buttonBarTheme', buttonBarTheme, defaultValue: defaultData.buttonBarTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('buttonTheme', buttonTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('cardTheme', cardTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('checkboxTheme', checkboxTheme, defaultValue: defaultData.checkboxTheme, level: DiagnosticLevel.debug)); @@ -2083,6 +2107,8 @@ class ThemeData with Diagnosticable { properties.add(DiagnosticsProperty('timePickerTheme', timePickerTheme, defaultValue: defaultData.timePickerTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('toggleButtonsTheme', toggleButtonsTheme, level: DiagnosticLevel.debug)); properties.add(DiagnosticsProperty('tooltipTheme', tooltipTheme, level: DiagnosticLevel.debug)); + // DEPRECATED (newest deprecations at the bottom) + properties.add(DiagnosticsProperty('buttonBarTheme', buttonBarTheme, defaultValue: defaultData.buttonBarTheme, level: DiagnosticLevel.debug)); } } diff --git a/packages/flutter/test_fixes/material/button_bar.dart b/packages/flutter/test_fixes/material/button_bar.dart new file mode 100644 index 0000000000..df858e80ab --- /dev/null +++ b/packages/flutter/test_fixes/material/button_bar.dart @@ -0,0 +1,14 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +void main() { + // Changes made in https://github.com/flutter/flutter/pull/145523 + ButtonBar(); + + // Changes made in https://github.com/flutter/flutter/pull/145523 + ThemeData theme = ThemeData(); + theme = ThemeData(buttonBarTheme: ButtonBarThemeData()); +} diff --git a/packages/flutter/test_fixes/material/button_bar.dart.expect b/packages/flutter/test_fixes/material/button_bar.dart.expect new file mode 100644 index 0000000000..41c6b06b0c --- /dev/null +++ b/packages/flutter/test_fixes/material/button_bar.dart.expect @@ -0,0 +1,14 @@ +// Copyright 2014 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +import 'package:flutter/material.dart'; + +void main() { + // Changes made in https://github.com/flutter/flutter/pull/145523 + OverflowBar(); + + // Changes made in https://github.com/flutter/flutter/pull/145523 + ThemeData theme = ThemeData(); + theme = ThemeData(); +}