mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-25 15:02:33 +01:00
29 lines
735 B
Dart
29 lines
735 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class MouseOverBuilder extends StatefulWidget {
|
|
final Function(BuildContext, bool) builder;
|
|
|
|
const MouseOverBuilder({Key key, this.builder}) : super(key: key);
|
|
@override
|
|
_MouseOverBuilderState createState() => _MouseOverBuilderState();
|
|
}
|
|
|
|
class _MouseOverBuilderState extends State<MouseOverBuilder> {
|
|
bool _hover = false;
|
|
|
|
void _toggleHover(bool hover) {
|
|
if (_hover != hover) {
|
|
setState(() => _hover = hover);
|
|
}
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MouseRegion(
|
|
onEnter: (_) => _toggleHover(true),
|
|
onExit: (_) => _toggleHover(false),
|
|
child: widget.builder != null ? widget.builder(context, _hover) : null,
|
|
);
|
|
}
|
|
}
|