Skip to content

Commit ecf4f2f

Browse files
authored
[material_ui] Remove obsolete SurfaceTint defaults template (#13276)
Work toward flutter/flutter#187899. Fixes flutter/flutter#188435. Surface tint is no longer recommended by the Material 3 specification, so it should not be migrated to the new gen_defaults. This PR removes the obsolete `SurfaceTint` template and generated defaults. The existing elevation and opacity values remain hard-coded in elevation_overlay.dart for backwards compatibility. The runtime behavior remains unchanged. ## Pre-Review Checklist
1 parent 48b67e1 commit ecf4f2f

5 files changed

Lines changed: 10 additions & 71 deletions

File tree

‎packages/material_ui/lib/src/elevation_overlay.dart‎

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ abstract final class ElevationOverlay {
3939
}
4040

4141
// Calculates the opacity of the surface tint color from the elevation by
42-
// looking it up in the token generated table of opacities, interpolating
42+
// looking it up in the legacy table of opacities, interpolating
4343
// between values as needed. If the elevation is outside the range of values
4444
// in the table it will clamp to the smallest or largest opacity.
4545
static double _surfaceTintOpacityForElevation(double elevation) {
@@ -156,26 +156,15 @@ class _ElevationOpacity {
156156
final double opacity;
157157
}
158158

159-
// BEGIN GENERATED TOKEN PROPERTIES - SurfaceTint
160-
161-
// Do not edit by hand. The code between the "BEGIN GENERATED" and
162-
// "END GENERATED" comments are generated from data in the Material
163-
// Design token database by the script:
164-
// dev/tools/gen_defaults/bin/gen_defaults.dart.
165-
166-
// dart format off
167-
// Surface tint opacities based on elevations according to the
168-
// Material Design 3 specification:
169-
// https://m3.material.io/styles/color/the-color-system/color-roles
170-
// Ordered by increasing elevation.
159+
// Surface tint is no longer recommended by the Material 3 specification, but
160+
// these values are preserved for backwards compatibility.
161+
// TODO(QuncCccccc): Remove the out-of-date surface tint feature, including
162+
// these values. https://github.com/flutter/flutter/issues/188435
171163
const List<_ElevationOpacity> _surfaceTintElevationOpacities = <_ElevationOpacity>[
172-
_ElevationOpacity(0.0, 0.0), // Elevation level 0
173-
_ElevationOpacity(1.0, 0.05), // Elevation level 1
174-
_ElevationOpacity(3.0, 0.08), // Elevation level 2
175-
_ElevationOpacity(6.0, 0.11), // Elevation level 3
176-
_ElevationOpacity(8.0, 0.12), // Elevation level 4
164+
_ElevationOpacity(0.0, 0.0), // Elevation level 0
165+
_ElevationOpacity(1.0, 0.05), // Elevation level 1
166+
_ElevationOpacity(3.0, 0.08), // Elevation level 2
167+
_ElevationOpacity(6.0, 0.11), // Elevation level 3
168+
_ElevationOpacity(8.0, 0.12), // Elevation level 4
177169
_ElevationOpacity(12.0, 0.14), // Elevation level 5
178170
];
179-
// dart format on
180-
181-
// END GENERATED TOKEN PROPERTIES - SurfaceTint

‎packages/material_ui/tool/gen_defaults/bin/gen_defaults.dart‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import '../templates/search_view_template.dart';
5050
// import '../templates/segmented_button_template.dart';
5151
// import '../templates/slider_template.dart';
5252
import '../templates/snackbar_template.dart';
53-
// import '../templates/surface_tint_template.dart';
5453
import '../templates/switch_template.dart';
5554
import '../templates/tabs_template.dart';
5655

@@ -113,7 +112,6 @@ Future<void> main(List<String> args) async {
113112
// const SegmentedButtonTemplateM3().generateFile(verbose: verbose);
114113
// const SliderTemplateM3().generateFile(verbose: verbose);
115114
const SnackbarTemplateM3().generateFile(verbose: verbose);
116-
// const SurfaceTintTemplateM3().generateFile(verbose: verbose);
117115
const SwitchTemplateM3().generateFile(verbose: verbose);
118116
const TabsTemplateM3().generateFile(verbose: verbose);
119117
const TextFieldTemplateM3().generateFile(verbose: verbose);

‎packages/material_ui/tool/gen_defaults/temporarily_excluded/generated/surface_tint_defaults.g.dart‎

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎packages/material_ui/tool/gen_defaults/temporarily_excluded/templates/surface_tint_template.dart‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

‎packages/material_ui/tool/gen_defaults/test/gen_defaults_test.dart‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ import '../templates/search_view_template.dart';
4646
// import '../templates/segmented_button_template.dart';
4747
// import '../templates/slider_template.dart';
4848
import '../templates/snackbar_template.dart';
49-
// import '../templates/surface_tint_template.dart';
5049
import '../templates/switch_template.dart';
5150
import '../templates/tabs_template.dart';
5251
import '../templates/template.dart';
@@ -880,11 +879,6 @@ void main() {
880879
expect(contents, contains('double get actionOverflowThreshold => 0.25'));
881880
});
882881

883-
test('SurfaceTintTemplateM3 emits M3 SurfaceTint defaults from tokens', () {
884-
// Intentionally empty, will be implemented during migration. See:
885-
// https://github.com/flutter/flutter/issues/187899
886-
});
887-
888882
test('SwitchTemplateM3 emits M3 Switch defaults from tokens', () {
889883
final String contents = _generateContents(const SwitchTemplateM3());
890884
expect(contents, contains('class _SwitchDefaultsM3 extends SwitchThemeData'));

0 commit comments

Comments
 (0)