selfprivacy.org.app/lib/ui/components/brand_button/filled_button.dart

42 lines
1.2 KiB
Dart
Raw Normal View History

2022-05-16 22:41:00 +00:00
import 'package:flutter/material.dart';
class FilledButton extends StatelessWidget {
const FilledButton({
2022-06-05 19:36:32 +00:00
final super.key,
2022-05-16 22:41:00 +00:00
this.onPressed,
this.title,
this.child,
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;
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(
onPrimary: Theme.of(context).colorScheme.onPrimary,
primary: Theme.of(context).colorScheme.primary,
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0));
2022-05-30 23:06:08 +00:00
final ButtonStyle disabledStyle = ElevatedButton.styleFrom(
onPrimary: Theme.of(context).colorScheme.onSurface.withAlpha(30),
primary: Theme.of(context).colorScheme.onSurface.withAlpha(98),
).copyWith(elevation: ButtonStyleButton.allOrNull(0.0));
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,
child: child ?? Text(title ?? ''),
),
2022-05-16 22:41:00 +00:00
);
}
}