-
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.3Found to occur in 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4Found to occur in 3.4frameworkflutter/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 version
Description
Steps to Reproduce
- Execute
flutter runon the code sample with a desktop device (tried on Windows and Web) - Hover with the cursor on top of the icon
Expected results:
The overlay color that is showed during the hovering adapts to the shape change in the animation
Actual results:
The overlay color that is showed during the hovering does not change during the button shape animation
flutter doctor -v
[✓] Flutter (Channel stable, 3.3.6, on Microsoft Windows [Versione 10.0.22621.755], locale it-IT)
• Flutter version 3.3.6 on channel stable at C:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 6928314d50 (5 days ago), 2022-10-25 16:34:41 -0400
• Engine revision 3ad69d7be3
• Dart version 2.18.2
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
• Android SDK at C:\Users\Damiano\AppData\Local\Android\sdk
• Platform android-33, build-tools 33.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Chrome - develop for the web
• Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
[✓] Visual Studio - develop for Windows (Visual Studio Community 2022 17.3.3)
• Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
• Visual Studio Community 2022 version 17.3.32825.248
• Windows 10 SDK version 10.0.19041.0
[✓] Android Studio (version 2021.3)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
[✓] VS Code (version 1.72.2)
• VS Code at C:\Users\Damiano\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.50.0
[✓] Connected device (3 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Versione 10.0.22621.755]
• Chrome (web) • chrome • web-javascript • Google Chrome 107.0.5304.88
• Edge (web) • edge • web-javascript • Microsoft Edge 105.0.1343.33
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Code sample
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: MyWidget(),
);
}
}
class MyWidget extends StatelessWidget {
const MyWidget({super.key});
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(child: AnimatedElevatedButton()),
);
}
}
class AnimatedElevatedButton extends StatefulWidget {
const AnimatedElevatedButton({super.key});
@override
State<AnimatedElevatedButton> createState() => _AnimatedElevatedButtonState();
}
class _AnimatedElevatedButtonState extends State<AnimatedElevatedButton>
with SingleTickerProviderStateMixin {
late final AnimationController _controller = AnimationController(
lowerBound: 0,
upperBound: 300,
value: 300,
duration: const Duration(seconds: 2),
vsync: this,
);
@override
Widget build(BuildContext context) {
return ElevatedButtonTransition(
radius: _controller,
onPressed: () {},
onHover: (value) => setState(() => _controller.value = value ? 80 : 150),
);
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
}
class ElevatedButtonTransition extends AnimatedWidget {
final void Function()? onPressed;
final void Function(bool)? onHover;
const ElevatedButtonTransition({
super.key,
this.onPressed,
this.onHover,
required AnimationController radius,
}) : super(listenable: radius);
Animation<double> get radius => listenable as Animation<double>;
@override
Widget build(BuildContext context) {
ButtonStyle style = ButtonStyle(
elevation: MaterialStateProperty.resolveWith<double?>(
(Set<MaterialState> states) => 0,
),
foregroundColor: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) =>
Theme.of(context).colorScheme.onSecondaryContainer,
),
backgroundColor: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) =>
Theme.of(context).colorScheme.secondaryContainer,
),
overlayColor: MaterialStateProperty.resolveWith<Color?>(
(Set<MaterialState> states) =>
states.contains(MaterialState.hovered) ? Colors.black26 : null,
),
shape: MaterialStateProperty.resolveWith<OutlinedBorder?>(
(Set<MaterialState> states) => RoundedRectangleBorder(
borderRadius: BorderRadius.circular(radius.value),
),
),
);
return ElevatedButton(
onPressed: onPressed,
onHover: onHover,
style: style,
child: const Icon(Icons.favorite, size: 300),
);
}
}
Metadata
Metadata
Assignees
Labels
f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 3.3Found to occur in 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4Found to occur in 3.4frameworkflutter/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 version
Type
Projects
Status
Done (PR merged)
