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

61 lines
1.6 KiB
Dart
Raw Normal View History

2020-11-29 22:07:46 +02:00
import 'package:flutter/material.dart';
2021-02-15 20:58:29 +02:00
class BrandButton {
2022-06-05 22:36:32 +03:00
static ConstrainedBox rised({
required final VoidCallback? onPressed,
final Key? key,
final String? text,
final Widget? child,
2021-02-15 20:58:29 +02:00
}) {
2021-05-26 00:53:54 +03:00
assert(text == null || child == null, 'required title or child');
assert(text != null || child != null, 'required title or child');
2022-05-17 01:41:00 +03:00
return ConstrainedBox(
2022-05-24 21:55:39 +03:00
constraints: const BoxConstraints(
2022-05-17 01:41:00 +03:00
minHeight: 48,
minWidth: double.infinity,
),
child: FilledButton(
key: key,
onPressed: onPressed,
2023-02-05 15:24:37 +02:00
child: child ?? Text(text ?? ''),
),
);
}
static ConstrainedBox filled({
required final VoidCallback? onPressed,
final Key? key,
final String? text,
final Widget? child,
}) {
assert(text == null || child == null, 'required title or child');
assert(text != null || child != null, 'required title or child');
return ConstrainedBox(
constraints: const BoxConstraints(
minWidth: double.infinity,
),
child: FilledButton(
key: key,
onPressed: onPressed,
2023-05-30 20:52:42 +03:00
style: ElevatedButton.styleFrom(
tapTargetSize: MaterialTapTargetSize.padded,
),
2023-02-05 15:24:37 +02:00
child: child ?? Text(text ?? ''),
2022-05-17 01:41:00 +03:00
),
2021-02-15 20:58:29 +02:00
);
}
2020-11-29 22:07:46 +02:00
2022-06-05 22:36:32 +03:00
static ConstrainedBox text({
required final VoidCallback onPressed,
required final String title,
final Key? key,
2020-11-30 12:03:55 +02:00
}) =>
2022-05-17 01:41:00 +03:00
ConstrainedBox(
2022-05-24 21:55:39 +03:00
constraints: const BoxConstraints(
minHeight: 40,
2022-05-17 01:41:00 +03:00
minWidth: double.infinity,
),
child: TextButton(onPressed: onPressed, child: Text(title)),
2020-11-30 12:03:55 +02:00
);
2020-12-03 18:52:53 +02:00
}