Search code examples
flutterlayoutrow

Align Items inside Row in flutter


I am new to flutter. I trying to design as in the image below. But I could not align the items inside the Row and could not give shape to like the layout below in the image. I have tried giving properties like mainAxisAlignment and crossAxisAlignment but could not get the expected result as in the image below.

enter image description here

Only I could able to get Image below.

enter image description here

I have implemented my code as follows:

    Container(
                              child: Column(
                                crossAxisAlignment:
                                    CrossAxisAlignment.start,
                                children: <Widget>[
                                  Checkbox(
                                      checkColor: Colors.white,
                                      activeColor: Colors.green,
                                      value: true,
                                      onChanged: (value) {
                                        print(value);
                                      }),
                                  Row(
                                    mainAxisSize: MainAxisSize.max,
                                    mainAxisAlignment:
                                        MainAxisAlignment.start,
                                    crossAxisAlignment:
                                        CrossAxisAlignment.start,
                                    children: <Widget>[
                                      Container(
                                          decoration: BoxDecoration(
                                              color: Colors.white,
                                              borderRadius:
                                                  BorderRadius.all(
                                                      Radius.circular(20))),
                                          child: Image.network(
                                            bannerWomenFashion[i],
                                            height: 100,
                                            width: 100,
                                            fit: BoxFit.scaleDown,
                                          )),
                                      SizedBox(
                                        width: 10,
                                      ),
                                      Expanded(
                                        child: Column(
                                          crossAxisAlignment:
                                              CrossAxisAlignment.start,
                                          mainAxisAlignment:
                                              MainAxisAlignment.start,
                                          children: <Widget>[
                                            Text(
                                              "Rs 1200",
                                              style: TextStyle(
                                                  color: CustomColor
                                                      .themeSecondary,
                                                  fontSize: 18,
                                                  fontWeight:
                                                      FontWeight.bold),
                                            ),
                                            SizedBox(
                                              height: 5,
                                            ),
                                            Text(
                                              "The Pursuit of Happiness",
                                              style: TextStyle(
                                                  color: Colors.blueGrey,
                                                  fontSize: 20,
                                                  fontWeight:
                                                      FontWeight.bold),
                                            ),
                                            SizedBox(
                                              height: 5,
                                            ),
                                            Text("ID: #254217",
                                                style: cartBlueGreyStyle),
                                          ],
                                        ),
                                      ),
                                      Expanded(
                                          child: Row(
                                        mainAxisSize: MainAxisSize.max,
                                        mainAxisAlignment:
                                            MainAxisAlignment.spaceBetween,
                                        crossAxisAlignment:
                                            CrossAxisAlignment.end,
                                        children: <Widget>[
                                          Row(
                                            children: <Widget>[
                                              Icon(
                                                Icons.remove,
                                                size: 25,
                                                color: Colors.blueGrey,
                                              ),
                                              Container(
                                                  width: 30,
                                                  height: 25,
                                                  decoration: BoxDecoration(
                                                    borderRadius:
                                                        BorderRadius
                                                            .circular(10),
                                                    color: Colors.white,
                                                    boxShadow: [
                                                      BoxShadow(
                                                          color:
                                                              Colors.grey,
                                                          spreadRadius: 2),
                                                    ],
                                                  ),
                                                  child: Center(
                                                      child: Text("1"))),
                                              Icon(
                                                Icons.add,
                                                size: 25,
                                                color: Colors.blueGrey,
                                              ),
                                            ],
                                          ),
                                        ],
                                      )),
                                      Container(
                                          width: 30,
                                          height: 30,
                                          decoration: BoxDecoration(
                                            borderRadius:
                                                BorderRadius.circular(20),
                                            color: Colors.white,
                                            boxShadow: [
                                              BoxShadow(
                                                  color: Colors.white,
                                                  spreadRadius: 2),
                                            ],
                                          ),
                                          child: Center(
                                            child: Icon(Icons.clear,
                                                color: Colors.blueGrey),
                                          )),
                                    ],
                                  ),
                                ],
                              ),
                            );

Solution

  • enter image description here

    Container(
      padding: EdgeInsets.all(32.0),
      child: IntrinsicHeight(
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: <Widget>[
            Stack(
              overflow: Overflow.visible,
              children: [
                Container(
                  padding: EdgeInsets.all( 8.0),
                    decoration: BoxDecoration(color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(12))),
                    child: Image.network(
                      'http://covertopia.com/wp-content/uploads/2015/05/000227_Alt.jpg'
                      /*bannerWomenFashion[i]*/,
                      height: 100,
                      fit: BoxFit.scaleDown,
                    )),
                Positioned(
                  top: -12,
                  left: -12,
                  child: Container(
                    width: 32,
                    height: 32,
                    decoration: BoxDecoration(color: Colors.green, borderRadius: BorderRadius.all(Radius.circular(12))),
                    child: Checkbox(
                        checkColor: Colors.white,
                        activeColor: Colors.green,
                        value: true,
                        onChanged: (value) {
                          print(value);
                        }),
                  ),
                )
              ],
            ),
            SizedBox(
              width: 10,
            ),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
    
                children: <Widget>[
                  Text(
                    "Rs 1200",
                    style: TextStyle(
                        color: Colors.red /*CustomColor
                            .themeSecondary*/
                        ,
                        fontSize: 18,
                        fontWeight: FontWeight.bold),
                  ),
                  SizedBox(height: 10,),
                  Expanded(
                    child: Align(
                      alignment: Alignment.centerLeft,
                      child: Text(
                        "The Pursuit of Happiness",
                        style: TextStyle(color: Colors.blueGrey, fontSize: 20, fontWeight: FontWeight.bold),
                      ),
                    ),
                  ),
                  SizedBox(height: 10,),
                  Row(
                    children: [
                      Text("ID: #254217", style: TextStyle(color: Colors.grey, fontWeight: FontWeight.bold) /*cartBlueGreyStyle*/),
                      Spacer(),
                      Row(
                        children: <Widget>[
                          Icon(
                            Icons.remove,
                            size: 25,
                            color: Colors.blueGrey,
                          ),
                          Container(
                              width: 30,
                              height: 25,
                              margin: EdgeInsets.symmetric(horizontal: 8),
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(10),
                                color: Colors.white,
                                boxShadow: [
                                  BoxShadow(color: Colors.blueGrey.withOpacity(0.1), spreadRadius: 2),
                                ],
                              ),
                              child: Center(child: Text("1"))),
                          Icon(
                            Icons.add,
                            size: 25,
                            color: Colors.blueGrey,
                          ),
                        ],
                      )
                    ],
                  ),
                ],
              ),
            ),
            Container(
                width: 30,
                height: 30,
                margin: EdgeInsets.symmetric(horizontal: 8),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(20),
                  color: Colors.white,
                  boxShadow: [
                    BoxShadow(color: Colors.white, spreadRadius: 2),
                  ],
                ),
                child: Center(
                  child: Icon(Icons.clear, color: Colors.blueGrey,size: 16,),
                )),
          ],
        ),
      ),
    );