xxxxxxxxxx
ElevatedButton.icon(
icon: Icon(Icons.home),
label: Text('ElevatedButton'),
onPressed: () {},
),
xxxxxxxxxx
TextButton.icon(
icon: Icon(Icons.camera),
label: Text('Take A Photo'),
onPressed: () {},
)
xxxxxxxxxx
ElevatedButton.icon(
onPressed: () {},
icon: Icon(Icons.email),
label: Text("Contact me"),
style: ElevatedButton.styleFrom(
textStyle: TextStyle(fontSize: 15),
),
),
xxxxxxxxxx
Flutter has WidgetSpan() to add a widget inside the RichText().
Example use:
RichText(
text: TextSpan(
children: [
TextSpan(
text: "Click ",
),
WidgetSpan(
child: Icon(Icons.add, size: 14),
),
TextSpan(
text: " to add",
),
],
),
)
Above code will produce:
Click + to add
You can treat the child of WidgetSpan like the usual widget.
xxxxxxxxxx
IconButton(
icon: Icon(
Icons.directions_transit,
),
onPressed: () {},
),
xxxxxxxxxx
IconButton(
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('Icon Button Clicked'),
),
);
},
icon: const Icon(Icons.add),
),
Use Column
xxxxxxxxxx
ElevatedButton(
onPressed: null,
child: Column(
children: [
Icon(Icons.favorite),
Text("Likes")
]
)
)
xxxxxxxxxx
RawMaterialButton(
onPressed: () {
// Handle button tap
},
shape: CircleBorder(),
fillColor: Theme.of(context).accentColor,
elevation: 4.0,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Icon(
Icons.keyboard,
color: Colors.white,
size: 24.0,
),
),
);