添加一个带有大小的按钮并在其中添加图标
Add a button with a size and add icon inside it in flutter
我正在尝试向按钮添加图标。
我遵循的步骤: 创建一个填充属性的图标按钮。
在此之后,我将它包裹在一个容器中,因为我不想让我的按钮变大。
这是我得到的图像:[![在此处输入图像描述][1]][1]
我想让那个图标适合按钮,我什至尝试用中心包裹 child 但结果仍然相同。
我的代码片段:
容器(
height:18,
width:20,
decoration:BoxDecoration(
border:Border.all(color:Colors.orangeAccent,宽度:1),
shape:BoxShape.矩形,
),
child:Centre(child:图标按钮(
icon:Icon(Icons.add,
size:16,
color:Colors.橙色,),
onPressed:(){},
),),
您可以使用 TextIconButton 而不是 IconButton。
你可以试试这个代码块
Container(
width: 50,
height: 50,
child: FlatButton(
onPressed: () {},
child: Row(
children: [
Icon(Icons.ac_unit),
Text('Add More')
],
),
),
)
您可以按照下面的代码执行最简单的方法。
Container(
width: 50,
height: 50,
child: GestureDetector(
onTap: () {},
child: Row(
children: [
Icon(Icons.ac_unit),
Padding(
padding: EdgeInsets.only(left: 10),
child: Text('Add More'),
)
],
),
),
)
我正在尝试向按钮添加图标。 我遵循的步骤: 创建一个填充属性的图标按钮。 在此之后,我将它包裹在一个容器中,因为我不想让我的按钮变大。 这是我得到的图像:[![在此处输入图像描述][1]][1]
我想让那个图标适合按钮,我什至尝试用中心包裹 child 但结果仍然相同。
我的代码片段: 容器( height:18, width:20, decoration:BoxDecoration( border:Border.all(color:Colors.orangeAccent,宽度:1), shape:BoxShape.矩形, ), child:Centre(child:图标按钮( icon:Icon(Icons.add, size:16, color:Colors.橙色,), onPressed:(){}, ),),
您可以使用 TextIconButton 而不是 IconButton。
你可以试试这个代码块
Container(
width: 50,
height: 50,
child: FlatButton(
onPressed: () {},
child: Row(
children: [
Icon(Icons.ac_unit),
Text('Add More')
],
),
),
)
您可以按照下面的代码执行最简单的方法。
Container(
width: 50,
height: 50,
child: GestureDetector(
onTap: () {},
child: Row(
children: [
Icon(Icons.ac_unit),
Padding(
padding: EdgeInsets.only(left: 10),
child: Text('Add More'),
)
],
),
),
)