BrandButton.rised rewrite as SPBrandButton widget
parent
42dd916729
commit
803530e959
|
@ -7,8 +7,9 @@ class BrandButton {
|
||||||
final String? text,
|
final String? text,
|
||||||
final Widget? child,
|
final Widget? 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, 'required title or child');
|
assert(text != null || child != null, 'title or child must be provided');
|
||||||
|
|
||||||
return ConstrainedBox(
|
return ConstrainedBox(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
minHeight: 48,
|
minHeight: 48,
|
||||||
|
@ -28,8 +29,9 @@ class BrandButton {
|
||||||
final String? text,
|
final String? text,
|
||||||
final Widget? child,
|
final Widget? 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, 'required title or child');
|
assert(text != null || child != null, 'title or child must be provided');
|
||||||
|
|
||||||
return ConstrainedBox(
|
return ConstrainedBox(
|
||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
minWidth: double.infinity,
|
minWidth: double.infinity,
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
export 'brand_button.dart';
|
||||||
|
export 'sp_brand_button.dart';
|
|
@ -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,
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue