2020-11-29 21:07:46 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2021-02-15 19:58:29 +01:00
|
|
|
class BrandButton {
|
2023-02-05 16:24:37 +03:00
|
|
|
static ConstrainedBox filled({
|
|
|
|
required final VoidCallback? onPressed,
|
|
|
|
final Key? key,
|
2024-10-30 16:05:39 +03:00
|
|
|
final String? title,
|
2023-02-05 16:24:37 +03:00
|
|
|
final Widget? child,
|
|
|
|
}) {
|
2024-10-30 16:05:39 +03:00
|
|
|
assert((title ?? child) != null, 'either title or child must not be empty');
|
|
|
|
assert(title != null || child != null, 'title or child must be provided');
|
2024-02-08 13:59:52 +02:00
|
|
|
|
2023-02-05 16:24:37 +03:00
|
|
|
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-12-28 20:07:30 +03:00
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
2023-05-30 20:52:42 +03:00
|
|
|
),
|
2023-12-28 20:07:30 +03:00
|
|
|
child: child ??
|
|
|
|
Text(
|
2024-10-30 16:05:39 +03:00
|
|
|
title ?? '',
|
2023-12-28 20:07:30 +03:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
2022-05-17 01:41:00 +03:00
|
|
|
),
|
2021-02-15 19:58:29 +01:00
|
|
|
);
|
|
|
|
}
|
2020-11-29 21:07:46 +01: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 11:03:55 +01:00
|
|
|
}) =>
|
2022-05-17 01:41:00 +03:00
|
|
|
ConstrainedBox(
|
2022-05-24 21:55:39 +03:00
|
|
|
constraints: const BoxConstraints(
|
2022-05-30 16:55:52 +03:00
|
|
|
minHeight: 40,
|
2022-05-17 01:41:00 +03:00
|
|
|
minWidth: double.infinity,
|
|
|
|
),
|
|
|
|
child: TextButton(onPressed: onPressed, child: Text(title)),
|
2020-11-30 11:03:55 +01:00
|
|
|
);
|
2020-12-03 17:52:53 +01:00
|
|
|
}
|