forked from firka/flutter
Migrate to Theme.brightnessOf method (#163950)
Refactor: Migrate to Theme.brightnessOf method fixes: #163837 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
This commit is contained in:
@@ -298,7 +298,7 @@ class _BottomAppBarDefaultsM2 extends BottomAppBarTheme {
|
||||
|
||||
@override
|
||||
Color? get color =>
|
||||
Theme.of(context).brightness == Brightness.dark ? Colors.grey[800]! : Colors.white;
|
||||
Theme.brightnessOf(context) == Brightness.dark ? Colors.grey[800]! : Colors.white;
|
||||
|
||||
@override
|
||||
Color? get surfaceTintColor => Theme.of(context).colorScheme.surfaceTint;
|
||||
|
||||
@@ -1465,7 +1465,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
|
||||
|
||||
Color get _iconColor {
|
||||
// These colors are not defined in the Material Design spec.
|
||||
final Brightness brightness = Theme.of(context).brightness;
|
||||
final Brightness brightness = Theme.brightnessOf(context);
|
||||
if (_enabled) {
|
||||
return widget.iconEnabledColor ??
|
||||
switch (brightness) {
|
||||
|
||||
@@ -173,7 +173,7 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM
|
||||
return widget.color!;
|
||||
}
|
||||
|
||||
return switch (Theme.of(context).brightness) {
|
||||
return switch (Theme.brightnessOf(context)) {
|
||||
Brightness.light => Colors.black54,
|
||||
Brightness.dark => Colors.white60,
|
||||
};
|
||||
|
||||
@@ -1002,7 +1002,7 @@ class _IconButtonM3 extends ButtonStyleButton {
|
||||
ButtonStyle? themeStyleOf(BuildContext context) {
|
||||
final IconThemeData iconTheme = IconTheme.of(context);
|
||||
final bool isDefaultSize = iconTheme.size == const IconThemeData.fallback().size;
|
||||
final bool isDefaultColor = identical(iconTheme.color, switch (Theme.of(context).brightness) {
|
||||
final bool isDefaultColor = identical(iconTheme.color, switch (Theme.brightnessOf(context)) {
|
||||
Brightness.light => kDefaultIconDarkColor,
|
||||
Brightness.dark => kDefaultIconLightColor,
|
||||
});
|
||||
|
||||
@@ -5070,7 +5070,7 @@ class _InputDecoratorDefaultsM2 extends InputDecorationTheme {
|
||||
|
||||
@override
|
||||
Color? get fillColor => MaterialStateColor.resolveWith((Set<MaterialState> states) {
|
||||
return switch ((Theme.of(context).brightness, states.contains(MaterialState.disabled))) {
|
||||
return switch ((Theme.brightnessOf(context), states.contains(MaterialState.disabled))) {
|
||||
(Brightness.dark, true) => const Color(0x0DFFFFFF), // 5% white
|
||||
(Brightness.dark, false) => const Color(0x1AFFFFFF), // 10% white
|
||||
(Brightness.light, true) => const Color(0x05000000), // 2% black
|
||||
@@ -5086,7 +5086,7 @@ class _InputDecoratorDefaultsM2 extends InputDecorationTheme {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return Theme.of(context).colorScheme.primary;
|
||||
}
|
||||
return switch (Theme.of(context).brightness) {
|
||||
return switch (Theme.brightnessOf(context)) {
|
||||
Brightness.dark => Colors.white70,
|
||||
Brightness.light => Colors.black45,
|
||||
};
|
||||
@@ -5100,7 +5100,7 @@ class _InputDecoratorDefaultsM2 extends InputDecorationTheme {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return Theme.of(context).colorScheme.primary;
|
||||
}
|
||||
return switch (Theme.of(context).brightness) {
|
||||
return switch (Theme.brightnessOf(context)) {
|
||||
Brightness.dark => Colors.white70,
|
||||
Brightness.light => Colors.black45,
|
||||
};
|
||||
@@ -5117,7 +5117,7 @@ class _InputDecoratorDefaultsM2 extends InputDecorationTheme {
|
||||
if (states.contains(MaterialState.focused)) {
|
||||
return Theme.of(context).colorScheme.primary;
|
||||
}
|
||||
return switch (Theme.of(context).brightness) {
|
||||
return switch (Theme.brightnessOf(context)) {
|
||||
Brightness.dark => Colors.white70,
|
||||
Brightness.light => Colors.black45,
|
||||
};
|
||||
|
||||
@@ -430,7 +430,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
|
||||
}
|
||||
|
||||
bool _isDark() {
|
||||
return Theme.of(context).brightness == Brightness.dark;
|
||||
return Theme.brightnessOf(context) == Brightness.dark;
|
||||
}
|
||||
|
||||
bool _isLabel() {
|
||||
@@ -593,7 +593,7 @@ class _StepperState extends State<Stepper> with TickerProviderStateMixin {
|
||||
);
|
||||
}
|
||||
|
||||
final Color cancelColor = switch (Theme.of(context).brightness) {
|
||||
final Color cancelColor = switch (Theme.brightnessOf(context)) {
|
||||
Brightness.light => Colors.black54,
|
||||
Brightness.dark => Colors.white70,
|
||||
};
|
||||
|
||||
@@ -2630,7 +2630,7 @@ class _TabsDefaultsM2 extends TabBarThemeData {
|
||||
|
||||
final BuildContext context;
|
||||
late final ColorScheme _colors = Theme.of(context).colorScheme;
|
||||
late final bool isDark = Theme.of(context).brightness == Brightness.dark;
|
||||
late final bool isDark = Theme.brightnessOf(context) == Brightness.dark;
|
||||
late final Color primaryColor = isDark ? Colors.grey[900]! : Colors.blue;
|
||||
final bool isScrollable;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user