BrandButton.rised rewrite as SPBrandButton widget

pull/444/head
Aliaksei Tratseuski 2024-01-31 07:48:07 +04:00 committed by aliaksei tratseuski
parent 42dd916729
commit 803530e959
3 changed files with 36 additions and 4 deletions

View File

@ -7,8 +7,9 @@ class BrandButton {
final String? text,
final Widget? child,
}) {
assert(text == null || child == null, 'required title or child');
assert(text != null || child != null, 'required title or child');
assert((text ?? child) != null, 'either title or child must not be empty');
assert(text != null || child != null, 'title or child must be provided');
return ConstrainedBox(
constraints: const BoxConstraints(
minHeight: 48,
@ -28,8 +29,9 @@ class BrandButton {
final String? text,
final Widget? child,
}) {
assert(text == null || child == null, 'required title or child');
assert(text != null || child != null, 'required title or child');
assert((text ?? child) != null, 'either title or child must not be empty');
assert(text != null || child != null, 'title or child must be provided');
return ConstrainedBox(
constraints: const BoxConstraints(
minWidth: double.infinity,

View File

@ -0,0 +1,2 @@
export 'brand_button.dart';
export 'sp_brand_button.dart';

View File

@ -0,0 +1,28 @@
import 'package:flutter/material.dart';
class SPBrandButton extends StatelessWidget {
const SPBrandButton({
required this.child,
required this.onPressed,
super.key,
});
SPBrandButton.text({
required final String title,
required this.onPressed,
super.key,
}) : child = Text(title);
final Widget child;
final VoidCallback onPressed;
@override
Widget build(final BuildContext context) => FilledButton(
// TODO(misterfourtytwo): move button styles to theme configuration
style: const ButtonStyle(
minimumSize: MaterialStatePropertyAll(Size.fromHeight(48)),
),
onPressed: onPressed,
child: child,
);
}