Fladder/lib/widgets/navigation_scaffold/components/adaptive_fab.dart
PartyDonut e7b5bb40ff
feat: UI 2.0 and other Improvements (#357)
Co-authored-by: PartyDonut <PartyDonut@users.noreply.github.com>
2025-06-01 10:37:19 +02:00

46 lines
974 B
Dart

import 'package:flutter/material.dart';
class AdaptiveFab {
final BuildContext context;
final String title;
final Widget child;
final Function() onPressed;
final Key? key;
AdaptiveFab({
required this.context,
this.title = '',
required this.child,
required this.onPressed,
this.key,
});
FloatingActionButton get normal {
return FloatingActionButton(
key: key,
onPressed: onPressed,
tooltip: title,
child: child,
);
}
Widget get extended {
return AnimatedContainer(
key: key,
duration: const Duration(milliseconds: 250),
height: 60,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 6),
child: FilledButton.tonal(
onPressed: onPressed,
child: Row(
spacing: 24,
children: [
child,
Flexible(child: Text(title)),
],
),
),
),
);
}
}