import 'package:flutter/material.dart'; import 'package:hexcolor/hexcolor.dart'; class RoundedContainer extends StatefulWidget { final double width; final double height; final double raduis; final Color backgroundColor; final double margin; final double elevation; final bool showBorder; final Color borderColor; final bool customCornerRaduis; final double topLeft; final double bottomRight; final double topRight; final double bottomLeft; final Widget child; final double borderWidth; final bool showShadow; RoundedContainer( {@required this.child, this.width, this.height, this.raduis = 10, this.backgroundColor = Colors.white, this.margin = 10, this.elevation = 1, this.showBorder = false, this.borderColor = Colors.red, this.customCornerRaduis = false, this.topLeft = 0, this.topRight = 0, this.bottomRight = 0, this.bottomLeft = 0, this.borderWidth = 1, this.showShadow = true}); @override _RoundedContainerState createState() => _RoundedContainerState(); } class _RoundedContainerState extends State { @override Widget build(BuildContext context) { return Container( width: widget.width, height: widget.height, margin: EdgeInsets.all(widget.margin), decoration: BoxDecoration( color: Theme .of(context) .primaryColor, border: widget.showBorder == true ? Border.all( color: widget.borderColor, width: widget.borderWidth) : null, borderRadius: widget.customCornerRaduis ? BorderRadius.only( topLeft: Radius.circular(widget.topLeft), topRight: Radius.circular(widget.topRight), bottomRight: Radius.circular(widget.bottomRight), bottomLeft: Radius.circular(widget.bottomLeft)) : BorderRadius.circular(widget.raduis), boxShadow: widget.showShadow ? [ BoxShadow( color: HexColor("#DBE5E6"), spreadRadius: 15, blurRadius: 15, offset: Offset(0, 7), // changes position of shadow ), ] : []) , child: Card( margin: EdgeInsets.all(0), shape: RoundedRectangleBorder( borderRadius: widget.customCornerRaduis ? BorderRadius.only( topLeft: Radius.circular(widget.topLeft), topRight: Radius.circular(widget.topRight), bottomRight: Radius.circular(widget.bottomRight), bottomLeft: Radius.circular(widget.bottomLeft)) : BorderRadius.circular(widget.raduis), ), color: widget.backgroundColor, child: widget.child, )); } }