-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
Labels
f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.26Found to occur in 3.26Found to occur in 3.26frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages team
Description
Steps to reproduce
- Run the sample code
- move the mouse over the Filter chip
Expected results
setting hoverColor shouldn't override the color for chips when hovered and the chip has a WidgetStateProperty set for the color that handles hover.
Actual results
It a) flashes red and then is grey b) it leaves a 1 device pixel red border.
Bonus mystery: If you put a breakpoint in the Chip build function where the Ink is built, the ink is never rebuilt with a different color, but is somehow actually redrawn with the hoverColor anyhow.
Code sample
Code sample
import 'package:flutter/material.dart';
void main() => runApp(const MaterialApp(home: MainApp()));
class MainApp extends StatefulWidget {
const MainApp({super.key});
@override
State<MainApp> createState() => _MainAppState();
}
class _MainAppState extends State<MainApp> {
final _selectedOptions = <String>[];
final String option = "filter";
@override
Widget build(BuildContext context) {
final chipTheme = Theme.of(context).chipTheme;
final colorScheme = Theme.of(context).colorScheme;
final chipThemeLabel =
chipTheme.labelStyle ?? Theme.of(context).textTheme.labelMedium!;
return Scaffold(
body: Theme(
data: ThemeData(
hoverColor: colorScheme.secondaryContainer, // Comment this out, and the hover color works properly again.
chipTheme: ChipThemeData(
color: WidgetStateProperty.resolveWith((states) {
if (states.contains(WidgetState.hovered) && states.contains(WidgetState.selected)) {
return colorScheme.primaryContainer.withAlpha(150);
}
if (states.contains(WidgetState.hovered)) {
return Colors.red;
}
if (states.contains(WidgetState.selected)) {
return colorScheme.primaryContainer;
}
return colorScheme.secondaryContainer;
}),
checkmarkColor: colorScheme.onSecondaryContainer,
shape: const StadiumBorder(
side: BorderSide(width: 0, color: Colors.transparent)),
padding: const EdgeInsets.all(4.0),
),
),
child: Center(
child: FilterChip(
labelStyle: chipThemeLabel.copyWith(
color: _selectedOptions.contains(option)
? Theme.of(context).colorScheme.onPrimaryContainer
: null,
),
label: Text(option),
selected: _selectedOptions.contains(option),
onSelected: (bool selected) => setState(
() {
if (selected) {
_selectedOptions.add(option);
} else {
_selectedOptions.remove(option);
}
},
),
),
),
),
);
}
}Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[✓] Flutter (Channel main, 3.26.0-1.0.pre.412, on Debian GNU/Linux rodete 6.9.10-1rodete5-amd64, locale
en_US.UTF-8)
• Flutter version 3.26.0-1.0.pre.412 on channel main at /usr/local/google/home/gspencer/code/flutter
• Upstream repository [email protected]:flutter/flutter.git
• Framework revision b9e71f7d12 (2 weeks ago), 2024-10-08 15:01:03 -0700
• Engine revision ea4a00f1c1
• Dart version 3.6.0 (build 3.6.0-332.0.dev)
• DevTools version 2.40.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
• Android SDK at /usr/local/google/home/gspencer/Android/Sdk
• Platform android-34, build-tools 33.0.1
• ANDROID_HOME = /usr/local/google/home/gspencer/Android/Sdk
• Java binary at: /usr/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.12+7-Debian-1build1)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at google-chrome
[✓] Linux toolchain - develop for Linux desktop
• Debian clang version 16.0.6 (26)
• cmake version 3.29.6
• ninja version 1.12.1
• pkg-config version 1.8.1
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/to/linux-android-setup for detailed instructions).
[✓] Connected device (2 available)
• Linux (desktop) • linux • linux-x64 • Debian GNU/Linux rodete 6.9.10-1rodete5-amd64
• Chrome (web) • chrome • web-javascript • Google Chrome 130.0.6723.69
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category.Metadata
Metadata
Assignees
Labels
f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.26Found to occur in 3.26Found to occur in 3.26frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-designOwned by Design Languages teamOwned by Design Languages team
Type
Projects
Status
Done (PR merged)