2022-05-16 22:41:00 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class FilledButton extends StatelessWidget {
|
|
|
|
const FilledButton({
|
2022-10-26 16:26:09 +00:00
|
|
|
super.key,
|
2022-05-16 22:41:00 +00:00
|
|
|
this.onPressed,
|
|
|
|
this.title,
|
|
|
|
this.child,
|
2022-05-26 01:02:06 +00:00
|
|
|
this.disabled = false,
|
2022-06-05 19:36:32 +00:00
|
|
|
});
|
2022-05-16 22:41:00 +00:00
|
|
|
|
|
|
|
final VoidCallback? onPressed;
|
|
|
|
final String? title;
|
|
|
|
final Widget? child;
|
2022-05-26 01:02:06 +00:00
|
|
|
final bool disabled;
|
2022-05-16 22:41:00 +00:00
|
|
|
|
|
|
|
@override
|
2022-06-05 19:36:32 +00:00
|
|
|
Widget build(final BuildContext context) {
|
2022-05-30 23:06:08 +00:00
|
|
|
final ButtonStyle enabledStyle = ElevatedButton.styleFrom(
|
2022-10-26 16:26:09 +00:00
|
|
|
foregroundColor: Theme.of(context).colorScheme.onPrimary,
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.primary,
|
2022-05-26 01:02:06 +00:00
|
|
|
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0));
|
|
|
|
|
2022-05-30 23:06:08 +00:00
|
|
|
final ButtonStyle disabledStyle = ElevatedButton.styleFrom(
|
2022-10-26 16:26:09 +00:00
|
|
|
foregroundColor: Theme.of(context).colorScheme.onSurface.withAlpha(30),
|
|
|
|
backgroundColor: Theme.of(context).colorScheme.onSurface.withAlpha(98),
|
2022-05-26 01:02:06 +00:00
|
|
|
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0));
|
|
|
|
|
2022-05-30 13:55:52 +00:00
|
|
|
return ConstrainedBox(
|
|
|
|
constraints: const BoxConstraints(
|
|
|
|
minHeight: 40,
|
|
|
|
minWidth: double.infinity,
|
|
|
|
),
|
|
|
|
child: ElevatedButton(
|
|
|
|
onPressed: onPressed,
|
2022-05-30 23:06:08 +00:00
|
|
|
style: disabled ? disabledStyle : enabledStyle,
|
2022-05-30 13:55:52 +00:00
|
|
|
child: child ?? Text(title ?? ''),
|
|
|
|
),
|
2022-05-16 22:41:00 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|