Search code examples
flutterflutter-layoutflutter-animationflutter-webflutter-container

FLUTTER : How can I make a custom flutter container?


I want to make a custom container/card that looks like:

expected outcome

How can I achieve overlapping/overlaying layout in flutter?


Solution

  • Code:

    Container(
      width: 135.0,
      height: 80.0,
      margin: EdgeInsets.only(right: 5.0),
      child: Stack(
        children: [
          Align(
            alignment: Alignment.centerLeft,
            child: Container(
              width: 110.0,
              height: 150.0,
              decoration: BoxDecoration(
                color: Colors.white,
                shape: BoxShape.rectangle,
                borderRadius: BorderRadius.all(Radius.circular(20.0)),
              ),
              child: Align(
                alignment: Alignment.bottomLeft,
                child: Padding(
                  padding: EdgeInsets.only(left: 15.0, bottom: 20.0),
                  child: Text(
                    text,
                    style: TextStyle(
                      fontSize: 15.0,
                      fontFamily: 'PlayfairDisplay',
                      color: kInactiveSearchPageTextColor,
                    ),
                  ),
                ),
              ),
            ),
          ),
          Align(
            alignment: Alignment.topLeft,
            child: Image.asset(
              image,
              width: 110,
              height: 110,
            ),
          ),
          Positioned(
            top: 162,
            left: 90,
            child: Container(
              width: 41.0,
              height: 41.0,
              child: RawMaterialButton(
                fillColor: Colors.white,
                shape: CircleBorder(),
                elevation: 12.0,
                child: Icon(
                  Icons.add,
                  color: kActiveSearchPageButtonColor,
                ),
                onPressed: onPressed,
              ),
            ),
          ),
        ],
      ),
    );