如何在行抖动中调整图标的填充/大小

时间:2020-01-23 10:18:59

标签: flutter containers row flutter-layout

Flutter-调整图标的大小 I have used multiple widgets to create buttons like containers 我想在此处减小图标的大小。有人可以建议我如何使用多个小部件连续调整图标的大小。

    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
            },
          ),
        );
      }

1 个答案:

答案 0 :(得分:1)

在您的height and width小部件中

放入 Image.asset,并根据需要缩小/调整大小

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
            },
          ),
        );
      }