Skip to content

Instantly share code, notes, and snippets.

@kodenatan17
Created November 23, 2022 07:09
Show Gist options
  • Save kodenatan17/ce20d0afdbca06bbbe0432ca064ecb83 to your computer and use it in GitHub Desktop.
Save kodenatan17/ce20d0afdbca06bbbe0432ca064ecb83 to your computer and use it in GitHub Desktop.
class TSRoundedBorder extends StatelessWidget {
final Color contentBackgroundColor;
final Color borderColor;
final Widget child;
final double borderRadius;
final double borderWidth;
final bool topLeft;
final bool topRight;
final bool bottomLeft;
final bool bottomRight;
const TSRoundedBorder({
required this.borderColor,
required this.contentBackgroundColor,
required this.child,
required this.borderRadius,
required this.borderWidth,
this.topLeft = false,
this.topRight = false,
this.bottomLeft = false,
this.bottomRight = false,
});
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: borderColor,
borderRadius: BorderRadius.only(
topLeft: topLeft ? Radius.circular(borderRadius) : Radius.zero,
topRight: topRight ? Radius.circular(borderRadius) : Radius.zero,
bottomLeft: bottomLeft ? Radius.circular(borderRadius) : Radius.zero,
bottomRight: bottomRight ? Radius.circular(borderRadius) : Radius.zero,
),
),
child: Container(
margin: EdgeInsets.only(
top: topLeft || topRight ? borderWidth : 0,
left: topLeft || bottomLeft ? borderWidth : 0,
bottom: bottomLeft || bottomRight ? borderWidth : 0,
right: topRight || bottomRight ? borderWidth : 0,
),
decoration: BoxDecoration(
color: contentBackgroundColor,
borderRadius: BorderRadius.only(
topLeft: topLeft ? Radius.circular(borderRadius - borderWidth) : Radius.zero,
topRight: topRight ? Radius.circular(borderRadius - borderWidth) : Radius.zero,
bottomLeft: bottomLeft ? Radius.circular(borderRadius - borderWidth) : Radius.zero,
bottomRight: bottomRight ? Radius.circular(borderRadius - borderWidth) : Radius.zero,
),
),
child: child,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment