SimpleCloudNotifier/flutter/lib/components/hidable_fab/hidable_fab.dart

28 lines
702 B
Dart
Raw Normal View History

2024-06-02 17:09:57 +02:00
import 'package:flutter/material.dart';
class HidableFAB extends StatelessWidget {
final VoidCallback? onPressed;
final IconData icon;
2024-07-13 00:11:13 +02:00
final Object heroTag;
2024-06-02 17:09:57 +02:00
const HidableFAB({
super.key,
this.onPressed,
required this.icon,
2024-07-13 00:11:13 +02:00
required this.heroTag,
2024-06-02 17:09:57 +02:00
});
Widget build(BuildContext context) {
return Visibility(
visible: MediaQuery.viewInsetsOf(context).bottom == 0.0, // hide when keyboard is shown
child: FloatingActionButton(
2024-07-13 00:11:13 +02:00
heroTag: this.heroTag,
2024-06-02 17:09:57 +02:00
onPressed: onPressed,
shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(17))),
elevation: 2.0,
child: Icon(icon),
),
);
}
}