Search code examples
fluttercontainersrowflutter-layout

How to adjust padding/size of a icon in a Row flutter


Flutter- adjust size of a iconI have used multiple widgets to create buttons like containers i want to reduce the size of icon here.can anyone suggest me how to adjust the size of icon in a row with multiple widgets.

    Widget buildFloatingButton() {
        return Container(
          height: 56.0,
          width: MediaQuery.of(context).size.width,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(10.0),
            image: DecorationImage(
                image: AssetImage("assets/images/btn1.png"), fit: BoxFit.cover),
          ),
          child: FlatButton(
            child: Row(//declared a row
              children: <Widget>[
                SizedBox(width: 16.0,),
                Image.asset("assets/images/video.png"),//icon image
                SizedBox(width: 20.0,),
                Text( //heading text
                  'Random Videos',
                  style: TextStyle(
                    fontSize: 20.0,
                    fontFamily: 'Righteous',
                    fontWeight: FontWeight.bold,
                  ),
                ),

              ],
            ),
            textColor: Colors.white, //setting colors
            color: Colors.transparent,
            shape:
            RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
            onPressed: () {
              print('button pressed');
              Navigator.pop(context);//button action call back
            },
          ),
        );
      }

Solution

  • Put height and width in your Image.asset widget and reduce/resize as per your requirement

    Widget buildFloatingButton() {
            return Container(
              height: 56.0,
              width: MediaQuery.of(context).size.width,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10.0),
                image: DecorationImage(
                    image: AssetImage("assets/images/btn1.png"), fit: BoxFit.cover),
              ),
              child: FlatButton(
                child: Row(//declared a row
                  children: <Widget>[
                    SizedBox(width: 16.0,),
                    Image.asset("assets/images/video.png",height: value,,width: value),//icon image
                    SizedBox(width: 20.0,),
                    Text( //heading text
                      'Random Videos',
                      style: TextStyle(
                        fontSize: 20.0,
                        fontFamily: 'Righteous',
                        fontWeight: FontWeight.bold,
                      ),
                    ),
    
                  ],
                ),
                textColor: Colors.white, //setting colors
                color: Colors.transparent,
                shape:
                RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
                onPressed: () {
                  print('button pressed');
                  Navigator.pop(context);//button action call back
                },
              ),
            );
          }