mirror of https://github.com/flutter/samples.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
52 lines
1.2 KiB
4 months ago
|
import 'package:flutter/material.dart';
|
||
|
|
||
|
import '../theme.dart';
|
||
|
|
||
|
class HighlightBorderOnHoverWidget extends StatefulWidget {
|
||
|
const HighlightBorderOnHoverWidget({
|
||
|
super.key,
|
||
|
required this.child,
|
||
|
this.color = MarketplaceTheme.secondary,
|
||
|
required this.borderRadius,
|
||
|
});
|
||
|
|
||
|
final Widget child;
|
||
|
final Color color;
|
||
|
final BorderRadius borderRadius;
|
||
|
|
||
|
@override
|
||
|
State<HighlightBorderOnHoverWidget> createState() =>
|
||
|
_HighlightBorderOnHoverWidgetState();
|
||
|
}
|
||
|
|
||
|
class _HighlightBorderOnHoverWidgetState
|
||
|
extends State<HighlightBorderOnHoverWidget> {
|
||
|
bool hovered = false;
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return MouseRegion(
|
||
|
onEnter: (event) {
|
||
|
setState(() {
|
||
|
hovered = true;
|
||
|
});
|
||
|
},
|
||
|
onExit: (event) {
|
||
|
setState(() {
|
||
|
hovered = false;
|
||
|
});
|
||
|
},
|
||
|
child: Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Theme.of(context).splashColor.withOpacity(.1),
|
||
|
border: Border.all(
|
||
|
color: hovered ? widget.color : MarketplaceTheme.borderColor,
|
||
|
),
|
||
|
borderRadius: widget.borderRadius,
|
||
|
),
|
||
|
child: widget.child,
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|