A button with an icon is used to act when tapped.
Properties:
- icon: The icon to display on the button.
- onPressed: The callback function when the button is pressed.
- tooltip: A message to display when the button is long-pressed.
- color: The color of the icon.
- iconSize: The size of the icon.
- padding: The padding around the icon.
- splashRadius: The radius of the splash effect when the button is pressed.
- highlightColor: The color of the highlight effect when the button is pressed.
- focusColor: The color of the focus effect when the button is focused.
- hoverColor: The color of the hover effect when the button is hovered.
IconButton(
icon: Icon(Icons.thumb_up),
color: Colors.deepPurple,
iconSize: 30,
tooltip: "Like",
onPressed: (){
// handle here
},
)
Code:
import 'package:flutter/material.dart';
class IconButtonDemo extends StatefulWidget {
const IconButtonDemo({Key? key}) : super(key: key);
@override
State<IconButtonDemo> createState() => _IconButtonDemoState();
}
class _IconButtonDemoState extends State<IconButtonDemo> {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
appBar: AppBar(
title: Text("Icon Button",style: TextStyle(color: Colors.white,fontWeight: FontWeight.bold),),
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Colors.deepPurple, Colors.orangeAccent],
begin: Alignment.topLeft,
end: Alignment.topRight,
)
),
),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
IconButton(
icon: Icon(Icons.thumb_up),
color: Colors.deepPurple,
iconSize: 30,
tooltip: "Like",
onPressed: (){
// handle here
},
)
],
),
),
);
}
}
Hi there to all,how iss everything, I think every one is getting more from this
website, and your views are pleasant in favor of new users.
please let us know how may we help you. You can text us on our fb page thank you.