Skip to content

Commit 38008b1

Browse files
Lance JohnstoneLance Johnstone
authored andcommitted
Added deprecation notice on switching between material2 and material3
1 parent afb8a9b commit 38008b1

2 files changed

Lines changed: 10 additions & 19 deletions

File tree

example/lib/platform_page.dart.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,7 @@ class PlatformPage extends StatelessWidget {
3636
: p.changeToMaterialPlatform();
3737
}),
3838
),
39-
if (isMaterial(context))
40-
Padding(
41-
padding: const EdgeInsets.all(8.0),
42-
child: PlatformElevatedButton(
43-
child: PlatformText(
44-
'Change to Material${Theme.of(context).useMaterial3 ? "" : " 3"}'),
45-
onPressed: () {
46-
final isMaterial3 = Theme.of(context).useMaterial3;
4739

48-
isMaterial3
49-
? PlatformTheme.of(context)?.changeToMaterial2(
50-
applyToBothDarkAndLightTheme: true)
51-
: PlatformTheme.of(context)?.changeToMaterial3(
52-
applyToBothDarkAndLightTheme: true);
53-
}),
54-
),
5540
Padding(
5641
padding: const EdgeInsets.all(8.0),
5742
child: PlatformElevatedButton(

lib/src/platform_theme.dart

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,20 @@ class _PlatformThemeState extends State<PlatformTheme>
102102
: themeMode == ThemeMode.dark;
103103
}
104104

105+
@Deprecated(
106+
'Switching to and from Material 2 and 3 is deprecated has no effect and wil be removed in the future.')
105107
void changeToMaterial3({bool applyToBothDarkAndLightTheme = false}) =>
106108
_setMaterialThemeType(
107-
useMaterial3: true,
108109
applyToBothDarkAndLightTheme: applyToBothDarkAndLightTheme);
109110

111+
@Deprecated(
112+
'Switching to and from Material 2 and 3 is deprecated has no effect and wil be removed in the future.')
110113
void changeToMaterial2({bool applyToBothDarkAndLightTheme = false}) =>
111114
_setMaterialThemeType(
112-
useMaterial3: false,
113115
applyToBothDarkAndLightTheme: applyToBothDarkAndLightTheme);
114116

115117
void resetMaterial({bool applyToBothDarkAndLightTheme = false}) {
116118
_setMaterialThemeType(
117-
useMaterial3: null,
118119
applyToBothDarkAndLightTheme: applyToBothDarkAndLightTheme);
119120
}
120121

@@ -123,7 +124,6 @@ class _PlatformThemeState extends State<PlatformTheme>
123124
false;
124125

125126
void _setMaterialThemeType({
126-
required bool? useMaterial3,
127127
bool applyToBothDarkAndLightTheme = false,
128128
}) {
129129
setState(() {
@@ -179,14 +179,20 @@ class PlatformThemeState {
179179
ThemeData? get materialLightTheme => _parent._materialLightTheme;
180180
ThemeData? get materialDarkTheme => _parent._materialDarkTheme;
181181

182+
@Deprecated(
183+
'Switching to and from Material 2 and 3 is deprecated has no effect and wil be removed in the future.')
182184
void changeToMaterial3({bool applyToBothDarkAndLightTheme = false}) =>
183185
_parent.changeToMaterial3(
184186
applyToBothDarkAndLightTheme: applyToBothDarkAndLightTheme);
185187

188+
@Deprecated(
189+
'Switching to and from Material 2 and 3 is deprecated has no effect and wil be removed in the future.')
186190
void changeToMaterial2({bool applyToBothDarkAndLightTheme = false}) =>
187191
_parent.changeToMaterial2(
188192
applyToBothDarkAndLightTheme: applyToBothDarkAndLightTheme);
189193

194+
@Deprecated(
195+
'Switching to and from Material 2 and 3 is deprecated has no effect and wil be removed in the future.')
190196
void resetToMaterialDefaultVersion(
191197
{bool applyToBothDarkAndLightTheme = false}) =>
192198
_parent.resetMaterial(

0 commit comments

Comments
 (0)