stack_wallet/lib/widgets/rounded_container.dart

63 lines
1.7 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
2022-08-26 08:11:35 +00:00
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
2022-08-26 08:11:35 +00:00
class RoundedContainer extends StatelessWidget {
const RoundedContainer({
Key? key,
this.child,
required this.color,
this.padding = const EdgeInsets.all(12),
2022-09-16 23:54:46 +00:00
this.radiusMultiplier = 1.0,
2022-09-18 17:27:38 +00:00
this.width,
this.height,
this.borderColor,
2023-02-02 21:37:59 +00:00
this.boxShadow,
this.onPressed,
2022-08-26 08:11:35 +00:00
}) : super(key: key);
final Widget? child;
final Color color;
final EdgeInsets padding;
2022-09-16 23:54:46 +00:00
final double radiusMultiplier;
2022-09-18 17:27:38 +00:00
final double? width;
final double? height;
final Color? borderColor;
2023-02-02 21:37:59 +00:00
final List<BoxShadow>? boxShadow;
final VoidCallback? onPressed;
2022-08-26 08:11:35 +00:00
@override
Widget build(BuildContext context) {
return ConditionalParent(
condition: onPressed != null,
builder: (child) => RawMaterialButton(
padding: const EdgeInsets.all(0),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius * radiusMultiplier,
),
2022-08-26 08:11:35 +00:00
),
onPressed: onPressed,
2022-08-26 08:11:35 +00:00
child: child,
),
child: Container(
width: width,
height: height,
decoration: BoxDecoration(
color: color,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius * radiusMultiplier,
),
border: borderColor == null ? null : Border.all(color: borderColor!),
boxShadow: boxShadow,
),
child: Padding(
padding: padding,
child: child,
),
),
2022-08-26 08:11:35 +00:00
);
}
}