mirror of
https://github.com/krille-chan/fluffychat
synced 2024-09-10 12:25:11 +00:00
29 lines
742 B
Dart
29 lines
742 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class HoverBuilder extends StatefulWidget {
|
|
final Widget Function(BuildContext context, bool hovered) builder;
|
|
const HoverBuilder({required this.builder, super.key});
|
|
|
|
@override
|
|
State<HoverBuilder> createState() => _HoverBuilderState();
|
|
}
|
|
|
|
class _HoverBuilderState extends State<HoverBuilder> {
|
|
bool hovered = false;
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MouseRegion(
|
|
onEnter: (_) => hovered
|
|
? null
|
|
: setState(() {
|
|
hovered = true;
|
|
}),
|
|
onExit: (_) => !hovered
|
|
? null
|
|
: setState(() {
|
|
hovered = false;
|
|
}),
|
|
child: widget.builder(context, hovered),
|
|
);
|
|
}
|
|
}
|